C++primer reordering of container elements

Source: Internet
Author: User

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&AMP;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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.