Hardwood Species

http://poj.org/problem?id=2418

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<string>
 4 #include<iostream>
 5 #include<map>
 6 #include<algorithm>
 7 using namespace std;
 8 char s[10000];
 9 int main(){
10 
11    //freopen("sb.txt","r",stdin);
12    long long cnt=0;
13    map<string,int>q;
14    while(gets(s))
15    {
16        cnt++;
17        if(q.find(s)==q.end())
18        {
19            q[s]=1;
20        }
21        else q[s]++;
22    }
23    map<string,int>::const_iterator inter=q.begin();
24    while(inter!=q.end())
25    {
26        cout<<inter->first;
27        printf(" %.4lf\n",inter->second*100.0/cnt);
28        inter++;
29    }
30    return 0;
31 }
View Code

 

posted @ 2013-08-21 10:44  null1019  阅读(159)  评论(0编辑  收藏  举报