运行 ❯
获取你的
自己
网站
×
更改方向
更改主题、深/浅色
转到 Spaces
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { vector<string> cars = {"Volvo", "BMW", "Ford", "Ford", "Mazda"}; auto it = adjacent_find(cars.begin(), cars.end()); if (it != cars.end()) { cout << *it << " appears twice in a row\n"; } else { cout << "There are no adjacent elements\n"; } return 0; }
Ford 连续两次出现