您的位置:首页 > 其它

acm pku 2418解题报告

2008-11-12 17:13 281 查看
这题用标准STL做十分简单,但是时间有点长,我的程序如下:

Problem: 2418User: zhao999
Memory: 440KTime: 3063MS
Language: C++Result: Accepted
Source Code
#include <iostream>
#include <map>
#include<string>
using namespace std;
int count=0;
int main ()
{
map<string,int> mymap;
map<string,int>::iterator it;
string a;
while(getline(cin,a))
{
if(a.length()==0)
break;
mymap[a]++;
count++;
}

for ( it=mymap.begin() ; it != mymap.end(); it++ )
{
cout << (*it).first << " ";
printf("%.4lf/n",100*(*it).second/(double)count);
}

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: