#include<iostream>
#include<string>
#include<set>
#include<sstream>
using namespace std;
set<string> dict;//string 集合
int main()
{
string s,buf;
while(cin>>s)//輸入字符串s
{
for(int i=0;i<s.length();i++)
if(isalpha(s[i])) s[i]=tolower(s[i]); else s[i]=' ';//si是字母把字符轉換成小寫
stringstream ss(s);//讀取s中的單字
while(ss>>buf) dict.insert(buf);
}
for(set<string>::iterator it =dict.begin();it!=dict.end();++it)//iterator相當於指針
cout<<*it<<endl;
return 0;
}
算法之路二:劉汝佳算法競賽入門經典:STL集合 安迪的第一個字典 UVA10851
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.