執行 ❯
建立您
自己的
網站
×
更改方向
更改主題,深色/淺色
前往 Spaces
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { vector<int> numbers = {1, 7, 3, 5, 9, 2}; sort(numbers.begin(), numbers.end()); auto it = lower_bound(numbers.begin(), numbers.end(), 4); if (it != numbers.end()) { cout << *it << " is the first value at or above 4"; } else { cout << "No elements found at or above the lower bound"; } return 0; }
5是第一個大於或等於4的值