运行 ❯
建立您
自己的
网站
×
更改方向
更改主题,深色/浅色
前往 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; }
福特连续出现了两次