執行 ❯
建立您
自己的
網站
×
更改方向
更改主題,深色/淺色
前往 Spaces
#include <iostream> #include <vector> #include <algorithm> using namespace std; bool greater_than_5(int value) { return value > 5; } int main() { vector<int> numbers = {1, 7, 3, 5, 9, 2}; int amount = count_if(numbers.begin(), numbers.end(), greater_than_5); cout << "There are " << amount << " values greater than 5."; return 0; }
有兩個數值大於 5。