vector<int> v = {72, 45, 88, 60, 93}; 想统计大于 60 分的元素个数。下列写法正确的是( )。
- A.
count(v.begin(), v.end(), 60)——数出 60 出现的次数 - B.
count_if(v.begin(), v.end(), [](int x) { return x > 60; })——把「大于 60」写成谓词交给 count_if - C.
count(v.begin(), v.end(), x > 60)——把条件表达式直接当第三个参数 - D.
v.count_if(x > 60)——vector 自带的成员函数