1#include <iostream>2#include <string>3#include <algorithm>4#include <fstream>5#include <vector>6#include <sstream>7 8 using namespacestd;9 Ten One BOOLIsshorter (Const string&S1,Const string&S2) A { - returnS1.size () <s2.size (); - } the - BOOLGT6 (Const string&s) { - returnS.size () >=6; - } + - + intMain () A { at ifstream infile; -Infile.open ("Input.txt"); - stringLine ; -vector<string>words; - - getline (infile,line); in Istringstream line1 (line); - stringWord; to while(line1>>word) + Words.push_back (word); - for(vector<string>::size_type num=0; Num!=words.size (); + +num) thecout<<words[num]<<" "; *cout<<Endl; $ Panax Notoginseng sort (Words.begin (), Words.end ()); - the for(vector<string>::size_type num=0; Num!=words.size (); + +num) +cout<<words[num]<<" "; Acout<<Endl; the +vector<string>::iterator end_unique= - Unique (Words.begin (), Words.end ()); $ $ - for(vector<string>::size_type num=0; Num!=words.size (); + +num) -cout<<words[num]<<" "; thecout<<Endl; - Wuyi words.erase (End_unique,words.end ()); the - Wu for(vector<string>::size_type num=0; Num!=words.size (); + +num) -cout<<words[num]<<" "; Aboutcout<<Endl; $ - Stable_sort (Words.begin (), Words.end (), isshorter); - - A for(vector<string>::size_type num=0; Num!=words.size (); + +num) +cout<<words[num]<<" "; thecout<<Endl; - $vector<string>::size_type wc=count_if (Words.begin (), Words.end (), GT6); thecout<<wc<<Endl; the the the}
Text content:
The quick red fox jumps over the slow red turtle
C++primer reordering of container elements