#include<bits/stdc++.h>
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]=' ';
}
stringstream ss(s);//读取str中的单字,比如hello world ,就会读取hello和world
while(ss>>buf)//ss>>buf意思是执行ss的一个名叫>>的函数,参数是 buf.即把ss中的内容复制(或移到)到buf中
dict.insert(buf);
}
for(set<string>::iterator it=dict.begin();it!=dict.end();++it)//iterator为set的一个迭代器
cout<<*it<<endl;//*(指针)--->指针所指向的地址内容
return 0;
}
例题5-3 安迪的第一个字典(Andy's First Dictionary,Uva 10815)
最新推荐文章于 2021-02-01 14:35:38 发布