uva156 By sixleaves
2015-06-04 23:42
176 查看
1 #include <iostream>
2 #include <string>
3 #include <algorithm>
4 #include <map>
5 #include <vector>
6 using namespace std;
7
8 map<string, int> cnt;
9 vector<string> words;
10
11 string formatWord(const string &s);
12
13 int main() {
14
15 string s;
16 while(cin >> s) {
17
18 if (s[0] == '#') break;
19 words.push_back(s);
20
21 string fw = formatWord(s);
22 if (!cnt.count(fw)) cnt[fw] = 0;
23 cnt[fw]++;
24 }
25
26 vector<string> ans;
27 for (int i = 0; i < words.size(); i++) {
28
29 if ( cnt[formatWord( words[i] ) ] == 1) ans.push_back(words[i]);
30 }
31
32 sort(ans.begin(), ans.end());
33 for (int i = 0; i < ans.size(); i++) {
34 cout << ans[i] << endl;
35 }
36 return 0;
37 }
38
39 string formatWord(const string &s) {
40
41 string ans = s;
42 int str_size = ans.size();
43 for (int i = 0; i <str_size; i++) {
44
45 ans[i] = tolower(ans[i]);
46
47 }
48 sort(ans.begin(), ans.end());
49 return ans;
50
51 }
2 #include <string>
3 #include <algorithm>
4 #include <map>
5 #include <vector>
6 using namespace std;
7
8 map<string, int> cnt;
9 vector<string> words;
10
11 string formatWord(const string &s);
12
13 int main() {
14
15 string s;
16 while(cin >> s) {
17
18 if (s[0] == '#') break;
19 words.push_back(s);
20
21 string fw = formatWord(s);
22 if (!cnt.count(fw)) cnt[fw] = 0;
23 cnt[fw]++;
24 }
25
26 vector<string> ans;
27 for (int i = 0; i < words.size(); i++) {
28
29 if ( cnt[formatWord( words[i] ) ] == 1) ans.push_back(words[i]);
30 }
31
32 sort(ans.begin(), ans.end());
33 for (int i = 0; i < ans.size(); i++) {
34 cout << ans[i] << endl;
35 }
36 return 0;
37 }
38
39 string formatWord(const string &s) {
40
41 string ans = s;
42 int str_size = ans.size();
43 for (int i = 0; i <str_size; i++) {
44
45 ans[i] = tolower(ans[i]);
46
47 }
48 sort(ans.begin(), ans.end());
49 return ans;
50
51 }
相关文章推荐
- JAVA反射会降低你的程序性能吗?
- eclipse 设置字体
- operator 与&operator
- 第二章第22题
- Insist
- UVA 400 Unix ls by sixleaves
- php构造http请求上传图片
- error LNK2005: __errno already defined in MSVCRTD.lib(MSVCR90D.dll)
- The best solution I found was to raise the Heap of the Application.
- Java-调试技巧(一)
- 内存分布
- Linux 环境下开发 常用指令
- UVA514 Rails
- 【算法】快速排序法:Quicksort
- 平衡二叉排序树的各种算法
- 不同JS环境use strict对重复属性处理的差异
- StringBuffer is dangerous when dealing with lonnnng Strings!!!
- Win7设置outlook2013开机自启动
- static与继承
- 一、文件安全与权限