#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
vector<int> vec = {1, 2, 3, 4, 5};
// 查找元素
auto it = find(vec.begin(), vec.end(), 3);
if (it != vec.end()) {
cout << "Element found: " << *it << endl;
}
// 查找满足条件的元素
auto it2 = find_if(vec.begin(), vec.end(), [](int x) { return x > 3; });
if (it2 != vec.end()) {
cout << "Element > 3 found: " << *it2 << endl;
}
// 统计元素个数
int num = count(vec.begin(), vec.end(), 2);
cout << "Number of 2s: " << num << endl;
// 比较两个范围
vector<int> vec2 = {1, 2, 3};
bool result = equal(vec.begin(), vec.end(), vec2.begin(), vec2.end());
if (result) {
cout << "Vectors are equal" << endl;
} else {
cout << "Vectors are not equal" << endl;
}
return 0;
}