1. 程式人生 > >安迪的第一個字典(UVa10815)

安迪的第一個字典(UVa10815)

font begin size code pac name lan str mil

  題目具體描述見:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1756

C++11代碼如下:

 1 #include<iostream>
 2 #include<set>
 3 #include<string>
 4 #include<sstream>
 5 using namespace std;
 6 set<string> dict;
 7 
 8 int
main() { 9 string s,buf; 10 while (cin >> s) { 11 for (int i = 0; i < s.length();i++) { 12 if (isalpha(s[i])) s[i]=tolower(s[i]); 13 else s[i] = ; 14 } 15 stringstream ss(s); 16 while(ss >> buf) dict.insert(buf); 17 }
18 for (set<string>::iterator it = dict.begin(); it != dict.end(); it++) 19 cout << *it << endl; 20 return 0; 21 }

安迪的第一個字典(UVa10815)