#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
bool isFind(string& arg)
{
return arg.size() > 4;
}
void fun_1110()
{
string input;
vector<string> words;
words.push_back("the");
words.push_back("quick");
words.push_back("red");
words.push_back("fox");
words.push_back("jumps");
words.push_back("over");
words.push_back("the");
words.push_back("slow");
words.push_back("red");
words.push_back("turtle");
sort(words.begin(), words.end());
vector<string>::iterator iter2 = unique(words.begin(), words.end());
words.erase(iter2, words.end());
vector<string>::iterator iter3 = words.begin();
int num = 0;
while((iter3 = find_if(iter3, words.end(), isFind)) != words.end())
{
cout<<*iter3<<endl;
num++;
iter3++;
}
cout<<"bigger than 4 words num is "<<num<<endl;
vector<string>::iterator iter = words.begin();
while(iter!= words.end())
{
cout<<*iter<<endl;
iter++;
}
}
《c++primer(第四版)》习题11.10
最新推荐文章于 2022-03-15 16:55:03 发布