第十六章第八题

#include<iostream>
using namespace std;
#include<vector>
#include<string>
#include<algorithm>
int main()
{
    
    
 vector<string> Mat, Pat, Total;
 string name;
 cout << "the Mat book title: ";
 while (getline(cin, name))
 {
    
    
  Mat.push_back(name);
  Total.push_back(name);
  if (name[0] == '\0')
   break;
 }
 cout << "the Mat book title: ";
 sort(Mat.begin(), Mat.end());
 for (auto i = Mat.begin(); i != Mat.end(); i++)
  cout << *i << "  ";
 cout << endl;
 cout << "the Pat book title: ";
 while (getline(cin, name))
 {
    
    
  Pat.push_back(name);
  Total.push_back(name);
  if (name[0] == '\0')
   break;
 }
 cout << "the Pat book title: ";
 sort(Pat.begin(), Pat.end());
 for (auto i = Pat.begin(); i != Pat.end(); i++)
  cout << *i << "  ";
 cout << endl;
 sort(Total.begin(), Total.end());
 unique(Total.begin(), Total.end());
 for (auto i = Total.begin(); i != Total.end(); i++)
  cout << *i << "  ";
 cout << endl;
 return 0;
}

猜你喜欢

转载自blog.csdn.net/wode_0828/article/details/108844209