第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

 

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

 

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

 

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

 

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

 

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

 

第16章 类和标准模板库

 

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

#include <string>
#include <vector>

struct Review{
     std::string title;
     int rating;
}
bool FillReview(Review & rr);
void ShowReview(const Review &rr);

int main(0
{
   using std::cout;
   using std::vector;
   vector<Review> books;
   Review temp;
   while {FillReview(temp))
   books.push_back(temp);
int num=books.size();
if (num>0)
{
   cout<<"Thank you you entered the folling:\n"<<"rating\tbook";
   for (int i=0;i<num;i++)
     showreview(books[i]);
   cout<<"repring:\n"<<"rating\tbppk\n";
   vector<review>::iterator pr;
   for (pr = books.begin();pr!=books.end();pr++)
       showreview(*pr);
   vector<review> oldlist(books);
   if(num>3)
   {
     books.ease(books.begin()+1,books.begin()+3);
     cout<<"after erasure:\n";
     for(pr=books.begin();pr!=books.end();pr++)
        showreview(*pr);
     books.insert(books.begin(),oldlist.begin()+1,oldlist.begin()+2);
     cout<<"after insertion:\n";
     for(pr=books.begin();pr!=books.end();pr++)
         showreview(*pr);
    }

   books.swap(oldlist);
   cout<<"swapping oldlis with books:\n";
   for (pr=books.begin();pr!=books.end();pr++)
     showreview(*pr);
}
  else
   cout<<"Nothing entered,nothing gained.\n";
   return 0;
}
bool fillreview(review & rr)
{
  std::cout<<"enter book title(quit to quit):";
  std::getline(std::cin,rr.title);
  if(rr.title == "quit")
    return false;
  std::cout<<"enter book rating:";
  std::cin>>rr.rating;
  if(!std::cin)
     return false;
  while (std:;cin.get()!='\n')
     continue;
  return true;
}
void showreview (const review && rr)
{
  std::cout<<rr.rating<<"\t"<<rr.title<<std:;endl;
}

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库第16章 类和标准模板库

 

第16章 类和标准模板库

第16章 类和标准模板库

第16章 类和标准模板库

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

相关文章: