W3School TIY Editor

  • W3School 在线教程
  • 改变方向
  • 暗黑模式
​x
 
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
​
int main() {
  // 创建整型向量 numbers
  vector<int> numbers = {1, 7, 3, 5, 9, 2};
​
  // 将向量按升序排序
  sort(numbers.begin(), numbers.end());
  
  // 在排序后的向量中查找第一个大于 5 的值
  auto it = upper_bound(numbers.begin(), numbers.end(), 5);
  
  cout << *it;
  
  return 0;
}