对容器元素进行排序

2014-11-23 19:52:26 · 作者: · 浏览: 8
#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;

bool isShorter(const string &s1,const string &s2)
{
	return s1.size()=6;
}
string make_plural(size_t ctr,const string &word, const string &ending)
{
	return (ctr==1) word:word+ending;//make_plural(wc, "word ", "s ")当输入中文本中
	                                     //word数大于一是在word后加s,为words为word的复数!
}
int main()
{
	//words:the quick red fox jumps over the slow red turtle
	vector words;
	vector::iterator noUnique;
	//将单词添加入vector
	words.push_back(string("the"));
	words.push_back(string("quick"));
	words.push_back(string("red"));
	words.push_back(string("fox"));
	words.push_back(string("jumps"));
	words.push_back(string("over"));
	words.push_back(string("the"));
	words.push_back(string("slow"));
	words.push_back(string("red"));
	words.push_back(string("turtle"));

	//原样输出单词
	cout<<"before sort:"<::iterator iter=words.begin();iter!=words.end();++iter)
	{
		cout << *iter<
::size_type wc=count_if(words.begin(),words.end(),GT6); cout<