#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
bool isCount(string& arg)
{
return arg.size() > 4;
}
void fun_1109()
{
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>::size_type num = count_if(words.begin(), words.end(), isCount);
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.9
最新推荐文章于 2023-02-16 21:04:46 发布