📄 119.cpp
字号:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
bool isShorter(const string &s1,const string &s2)
{
return s1.size()<s2.size();
}
bool GT4(const string &s)
{
return s.size() >=4;
}
void main()
{
vector<string> words;
string word;
while(cin>>word){
words.push_back(word);
}
sort(words.begin(),words.end());
vector<string>::iterator it=words.begin();
for(;it!=words.end();it++)
{
cout<<*it<<" ";
}
cout<<endl;
vector<string>::iterator end_unique=unique(words.begin(),words.end());
words.erase(end_unique,words.end());
it=words.begin();
for(;it!=words.end();it++)
{
cout<<*it<<" ";
}
cout<<endl;
stable_sort(words.begin(),words.end(),isShorter);
it=words.begin();
for(;it!=words.end();it++)
{
cout<<*it<<" ";
}
cout<<endl;
vector<string>::size_type wc=count_if(words.begin(),words.end(),GT4);
cout<<wc<<" words:6 characters or longer"<<endl;
it=find_if(words.begin(),words.end(),GT4);
if(it!=words.end())
{
for(;it!=words.end();it++)
{
cout<<*it<<" ";
}
cout<<endl;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -