集合:和离散数学上的集合一样,就是只出现一次,<set>里的元素已经从小到大排好了

#include<iostream>
#include<string>
#include<set>
#include<sstream>
using namespace std;
set<string> dict;
int main()
{
string s, buf;
while(cin >> s) {
for(int i= 0; i < s.length(); i++)
if(isalpha(s[i])) s[i] = tolower(s[i]); else s[i] = ' ';//tolower是把大写换小写
stringstream ss(s);//把普通的字符串转换成可读入set的流
while(ss >> buf) dict.insert(buf);//这两部把更改后的字符串读入集合
}
//*****************************************************************
for(set<string>::iterator it = dict.begin(); it != dict.end(); ++it)
//*****************************************************************
//迭代器,便利输出,效果和数组一样
cout << *it << "\n";
return 0;
}