posts - 195,  comments - 30,  trackbacks - 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;
}

#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 阅读(372) 评论(0)  编辑 收藏 引用 所属分类: 给我启发题
<2011年2月>
303112345
6789101112
13141516171819
20212223242526
272812345
6789101112

常用链接

留言簿(3)

随笔分类

随笔档案

文章分类

文章档案

友情链接

搜索

  •  

最新评论

阅读排行榜

评论排行榜