poj 2418 Hardwood Species(使用STL map)

来源:互联网 发布:彩虹秒赞 v7源码 编辑:程序博客网 时间:2024/05/01 11:38
//poj 2418 Hardwood Species(使用STL map)#include<iostream>#include<cstdio>#include<string>#include<iostream>#include<map>using namespace std;map<string,int> mp;map<string,int>::iterator it;int main(){    char a[33];    string str;    int n=0;    while(gets(a)!=NULL)    {        str=a;        mp[str]++;        n++;    }    for(it=mp.begin();it!=mp.end();it++)    {        cout<<it->first<<" ";        printf("%0.4lf\n",((double)(it->second)/(double)n)*100);    }    return 0;}

0 0
原创粉丝点击