1 #include <iostream> 2 #include <string> 3 #include <vector> 4 #include <algorithm> 5 using namespace std; 6 14 int main(int argc, const char *argv[]) 15 { 16 vector<int> vec; 17 18 vec.push_back(99); 19 vec.push_back(87); 20 vec.push_back(59); 21 vec.push_back(43); 22 vec.push_back(78); 23 vec.push_back(91); 24 25 26 int cnt = 27 std::count_if(vec.begin(), vec.end(), 28 [](int i){return i >= 80;});//lamdba表达式 29 cout << cnt << endl; 30 31 32 return 0; 33 }
时间: 2024-11-10 14:42:35