64,646
社区成员
发帖
与我相关
我的任务
分享
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
class GT_cls
{
public:
GT_cls(int val):bound(val){}
bool operator()(const string &s)
{
return s.size() >= bound;
}
private:
int bound;
};
int main()
{
vector<string> str;
string s;
while(cin>>s)
str.push_back(s);
cin.clear();
for(int i=0;i<10;i++)
cout<<count_if(str.begin(),str.end(),GT_cls(3))<<" words "<<i<<" characters or longer"<<endl;
return 0;
}
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
class GT_cls
{
pubilc:
GT_cls(int val):bound(val){}
bool operator()(const string &s)
{
return s.size()>=bound;
}
private:
int bound;
};
int main()
{
vector<string> str;
string s;
while(cin>>s)
str.push_back(s);
cin.clear();
for(int i=0;i<10;i++)
cout<<count_if(str.begin(),str.end(),gt_cle())<<" words "<<i<<" characters or longer"<<endl;
return 0;
}