#include<cstdio>
#include<iostream>
#include<cstring>
#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]);//string的isalpha(),tolower()函數
else s[i]=' ';
}
stringstream ss(s);// s爲string類型 如果s爲 hello world 則ss將hello與world分開保存 再依次輸入buf
while(ss>>buf) dict.insert(buf);
}
for(set<string>::iterator it=dict.begin();it!=dict.end();it++)
cout<<*it<<endl;
//system("pause");
return 0;
}
入門經典-5.2.3集合:set-112-uva10815安迪的字典-string,sstream,iterator,set⭐⭐⭐⭐⭐難度:1
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.