10420 - List of Conquests

C++语言: Codee#25825
01 /*
02 +++++++++++++++++++++++++++++++++++++++
03                 author: chm
04 +++++++++++++++++++++++++++++++++++++++
05 */
06
07 #include <map>
08 #include <set>
09 #include <list>
10 #include <queue>
11 #include <cmath>
12 #include <stack>
13 #include <bitset>
14 #include <cstdio>
15 #include <cctype>
16 #include <string>
17 #include <vector>
18 #include <cassert>
19 #include <cstdlib>
20 #include <cstring>
21 #include <fstream>
22 #include <sstream>
23 #include <iomanip>
24 #include <iostream>
25 #include <algorithm>
26
27 using namespace std;
28
29 FILE*            fin         = stdin;
30 FILE*            fout         = stdout;
31 const int        max_size     = 10086;
32 char line[max_size];
33 map<string, int> country;
34 int main()
35 {
36
37     int n;
38     char tmp[99];
39     char ch;
40     cin>>n;
41     cin.get();
42     while(n--)
43     {
44         cin.getline(line, sizeof(line));
45         sscanf(line, "%s", tmp);
46         string str(tmp);
47         ++country[str];
48     }
49     for(map<string, int>::iterator it = country.begin(), itend = country.end();
50             it != itend; ++it)
51         cout << it->first << " " << it->second << endl;
52     return 0;
53 }
posted @ 2012-03-15 09:57  strorehouse  阅读(178)  评论(0编辑  收藏  举报