UVA

 1 #include <iostream>
 2 #include <cstring>
 3 #include <algorithm>
 4 #include <set>
 5 using namespace std;
 6 
 7 set<string> out;
 8 
 9 int main()
10 {
11     string s,temp;
12     while(cin>>s)
13     {
14         int len(s.size());
15         for(int i=0;i<len;i++) s[i] = tolower(s[i]);
16         temp.clear();
17 
18         for(int i=0;i<len;i++)
19         {
20             if('a'<=s[i]&&s[i]<='z') temp.push_back(s[i]);
21             else
22             {
23                 if(temp.size() != 0)
24                 {
25                     out.insert(temp);
26                     temp.clear();
27                 }
28             }
29             if(i == len - 1)
30             {
31                 if(temp.size() != 0)
32                 {
33                     out.insert(temp);
34                 }
35             }
36         }
37     }
38     for(set<string>::iterator it=out.begin();it!=out.end();it++)
39         cout<<*it<<endl;
40 }
View Code
原文地址:https://www.cnblogs.com/NWUACM/p/6426301.html