运行 ❯
获取您自己的网站
×
更改方向
更改主题,深色/浅色
转到 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()); if (binary_search(numbers.begin(), numbers.end(), 5)) { cout << "The number 5 was found!"; } else { cout << "The number 5 was not found."; } return 0; }
找到了数字 5!