下面程序用STL的条件计数算法和自定义的函数对象对一个
下面程序用STL的条件计数算法和自定义的函数对象对一个存放在整数向量类对象中的学生成绩进行统计及格人数并显示结果。请在下面程序的横线处填上适当字句,以使程序完整。
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
class Pass
{
public:
____________________(1)___________________
{
return x>=60;
}
};
int main()
{
vector<int> a;
}
void disp(){cout<<"n="<<n<<endl;}
};
intmain()
{Sample s(10);
s--;
s.disp();
}
int count;
a.push_back(78);
a.push_back(92);
a.push_back(52);
count = ____________________(2)___________________;
cout<<"count="<<count<<endl;
}答案
第1空:bool operator()(int x)
第2空:count_if(a.begin(),a.end(),Pass())