chapter16test8

原创 2015年07月07日 15:35:23
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
void show(string &s);
int main()
{
vector<string>list1; vector<string>list2;
string temp;
cout << "Mat ,your turn :\n";
while (getline(cin, temp) && temp != "quit")
list1.push_back(temp);
cout << "Pat ,your turn :\n";
while (getline(cin, temp) && temp != "quit")
list2.push_back(temp);
sort(list1.begin(), list1.end());
sort(list2.begin(), list2.end());
cout << "Here is Mat's friend :\n";
for_each(list1.begin(), list1.end(), show);
cout << "Here is Pat's friend :\n";
for_each(list2.begin(), list2.end(), show);
vector<string>list3(list1.size()+list2.size());
merge(list1.begin(), list1.end(), list2.begin(), list2.end(), list3.begin());
list3.erase(unique(list3.begin(), list3.end()),list3.end());
cout << "Here are you tow's friend :\n";
for_each(list3.begin(), list3.end(), show);
return 0;
}
void show(string &s)
{
cout << s << endl;
}
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:chapter16test8
举报原因:
原因补充:

(最多只允许输入30个字)