百度之星 06初赛最后一题

题目:请编写程序,从包含大量单词的文本中删除出现次数最少的单词。如果有多 个单词都出现最少的次数,则将这些单词都删除。 程序: #include #include #include #include using namespace std; class coun; class cmp; struct info{ int sum; string str; info():sum(0){} info& operator=(string& p){++sum;str=p;return *this;} }; class coun{ vector inf; int sor(); public: void in(string&); friend void dele(coun&,vector&); }; class cmp{ public: bool operator()(const info& a,const info& b){return (a.sum)<(b.sum);} }; int main(){ vector txt; coun co; string tem; while(cin>>tem) { if(tem=="end")break; else txt.push_back(tem); } for(int i=0;i>p; return 0; } int coun::sor(){ sort(inf.begin(),inf.end(),cmp()); int i=1; for( ;i& txt){ int ite=cou.sor(); for(int i=0;i

你可能感兴趣的:(String,vector,struct,百度,Class)