#include <string> #include <vector> #include <iostream> #include <algorithm> using namespace std; 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的复数! } //comparison function to be used to sort by word length bool is_shorter(const string &s1,const string &s2) { return s1.size()<s2.size(); } //determine whether a length of a given word is 6 or more bool GT6(const string &s) { return s.size()>=6; } //main int main() { vector<string> words; //copy contents of each book into a single vector string next_word; while (cin>>next_word) { //insert next book's content at end of words words.push_back(next_word); } //sort words alphabetically for finding the duplicates sort(words.begin(),words.end()); //eliminate duplicate words vector<string>::iterator end_unique=unique(words.begin(),words.end()); words.erase(end_unique,words.end()); stable_sort(words.begin(),words.end(),is_shorter); vector<string>::size_type wc=count_if(words.begin(),words.end(),GT6); cout<<wc<<" "<<make_plural(wc,"word","s") <<" 6 characters or longer"<<endl; }
您还没有登录,请您登录后再发表评论
cppprimer.txt c++ primer c++的教程
高清电子书 CPP Primer c++
CPP_Primer习题供有需要的同学享用,课程资源共享
Cpp Primer Plus第6版源码
Cpp_Primer4rd.chm 更改了其中几个错误
C++ primer 第5版参考习题,需要的可自取。
001.CppPrimer_快速入门.mp4
002.CppPrimer_基本内置类型.mp4
自己几年前整理的C++ Primer的学习笔记
C++primer第五版答案
CppPrimer, C 引物 5th 练习的解决方案 用于 C 引物 5th 答案的解决方案 注释使用 GCC 4.9 。Clang 3.4 。MSVC 14 和其他语言。使用 -std=c 11 ( 推荐:-pedantic -Wall ) 标志进行编
C++ Primer第五版课后答案及示例代码
大部分人提供的是自己写的粗糙代码。这个从github可以下载得到。 如果能去git的就去给这个作者star吧。里面的习题答案是markdown格式,自行百度怎么使用。
CPP.Primer中文版(第4版) 经典之作,无需多说,值得拥有。PART1(2-1,两部分)
C++ Primer Plus 6 程序清单
Cpp_Primer3rd_Edition,大家都知道的,不用说了吧???
cpp_primer4配书原码,很不错,值得注意
cpp-primer-code.rar c++编程资料
cpp_primer4课后习题源代码.rar,包含c++ primer4 书中后面习题的源代码。
我的C++页面简介这些是我在第 5 版中解决问题的程序。 Lippman、Lajoie 和 Moo 的C++ Primer 。... 命令-Wall启用了许多警告,您可以在第 57 页上阅读这些警告, g++ exercisex_x.cpp告诉编译器如何(C++)以
相关推荐
cppprimer.txt c++ primer c++的教程
高清电子书 CPP Primer c++
CPP_Primer习题供有需要的同学享用,课程资源共享
Cpp Primer Plus第6版源码
Cpp_Primer4rd.chm 更改了其中几个错误
C++ primer 第5版参考习题,需要的可自取。
001.CppPrimer_快速入门.mp4
002.CppPrimer_基本内置类型.mp4
自己几年前整理的C++ Primer的学习笔记
C++primer第五版答案
CppPrimer, C 引物 5th 练习的解决方案 用于 C 引物 5th 答案的解决方案 注释使用 GCC 4.9 。Clang 3.4 。MSVC 14 和其他语言。使用 -std=c 11 ( 推荐:-pedantic -Wall ) 标志进行编
C++ Primer第五版课后答案及示例代码
大部分人提供的是自己写的粗糙代码。这个从github可以下载得到。 如果能去git的就去给这个作者star吧。里面的习题答案是markdown格式,自行百度怎么使用。
CPP.Primer中文版(第4版) 经典之作,无需多说,值得拥有。PART1(2-1,两部分)
C++ Primer Plus 6 程序清单
Cpp_Primer3rd_Edition,大家都知道的,不用说了吧???
cpp_primer4配书原码,很不错,值得注意
cpp-primer-code.rar c++编程资料
cpp_primer4课后习题源代码.rar,包含c++ primer4 书中后面习题的源代码。
我的C++页面简介这些是我在第 5 版中解决问题的程序。 Lippman、Lajoie 和 Moo 的C++ Primer 。... 命令-Wall启用了许多警告,您可以在第 57 页上阅读这些警告, g++ exercisex_x.cpp告诉编译器如何(C++)以