思路
set(去重 + 排序, 包含set头文件) + stringstream(分割空格or制表符隔开的字符串, 包含sstream头文件)
set:
1. insert()
2. iterator遍历, begin(), end()
#include <iostream>
#include <cstring>
#include <algorithm>
#include <set>
#include <sstream>
using namespace std;
set<string> s;
string a, b;
int main()
{
while(cin >> a)
{
for(int i = 0; i < a.length(); i ++ )
{
if(isalpha(a[i]))
a[i] = tolower(a[i]);
else
a[i] = ' ';
}
stringstream ss(a);
while(ss >> b)
s.insert(b);
}
for(set<string>::iterator it = s.begin(); it != s.end(); it ++ )
cout << *it << endl;
return 0;
}
牛逼