#include<iostream>
#include<string>
#include<map>
using namespace std;
int main()
{
//freopen("s.txt","r",stdin);
//freopen("key.txt","w",stdout);
string s;
int g=0;
while(getline(cin,s))
{
if (g) cout<<endl;
g=1;
int sum=0;
map<string,int> a;
while(s!="")
{
a[s]++;
sum++;
getline(cin,s);
}
cout.flags(ios::fixed);
cout.precision(4);
for (map<string,int>::iterator p=a.begin();p!=a.end();p++)
cout<<p->first<<" "<<100.0*p->second/sum<<endl;
}
return 0;
}
#include<iostream>
#include<string>
#include<map>
using namespace std;
int main()
{
freopen("s.txt","r",stdin);
freopen("key.txt","w",stdout);
string s;
int g=0;
while(getline(cin,s))
{
if (g) cout<<endl;
g=1;
int sum=0;
map<string,int> a;
while(s!="")
{
a[s]++;
sum++;
getline(cin,s);
}
cout.flags(ios::fixed);
cout.precision(4);
for (map<string,int>::iterator p=a.begin();p!=a.end();p++)
cout<<p->first<<" "<<100.0*p->second/sum<<endl;
}
return 0;
}
posted on 2009-06-27 09:05
luis 阅读(384)
评论(0) 编辑 收藏 引用 所属分类:
给我启发题