算典05_例题_03_UVA-10815
2017-04-01 19:05
288 查看
Andy’s First Dictionary
题意
输入一些文本,将其中出现过的单词(大小写都换成小写),按字典序输出题解
水题。集合set的用法,set中的元素默认是有序的这题之所以可以用set就是考虑到输入的文本中可能会出现大量重复的单词,所以用set即可避免重复,其实不用set只要能去掉重复的单词也是可以的
#include <iostream> #include <cstdio> #include <queue> #include <cstring> #include <algorithm> #include <cmath> #include <vector> #include <string> #include <sstream> #include <set> #include <map> using namespace std; const int maxn = 1e2 + 5; const int INF = (1<<31)-1; #define met(a, b) memset(a, b, sizeof(a)); #define IN freopen("in.txt", "r", stdin); typedef long long LL; string s, a; set<string> Set; int main(){ #ifdef _LOCAL IN; #endif // _LOCAL 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); while(ss >> a) Set.insert(a); } set<string>::iterator it = Set.begin(); for(; it!= Set.end(); ++it) { cout << (*it) <<endl; } return 0; }
相关文章推荐
- 算典03_例题_05_Uva-1583
- 算典04_例题_03_UVA-133
- 例题 5-3 安迪的第一个字典(Andy's First Dictionary) UVa 10815
- 算典03_例题_04_Uva-340
- 算典05_例题_10_UVA-207
- 算典05_例题_02_UVA-101
- 算典05_例题_11_UVA-814
- 算典03_例题_06_Uva-1584
- 算典03_习题_05_Uva-227
- 算典04_例题_05_UVA-512
- 算典05_例题_05_UVA-12096
- 字符串与数组03-例题-2 (WERTYU,UVa 10082)
- 【例题5-3 UVA - 10815】Andy's First Dictionary
- 算典05_例题_12_UVA-221
- 算法竞赛入门经典第五章例题5-3 Andy's First Dictionary UVA - 10815
- 例题:安迪的第一个字典(UVa 10815)
- 算典05_例题_04_UVA-156
- 算典05_例题_09_UVA-1592
- 算典03_例题_01_Uva-272
- 算典05_例题_06_UVA-540