#include <iostream>
#include <string>
#include <map>
#include <iterator>
#include <cstdio>
using namespace std;
int main()
{
    string s;
    int cnt=0;
    map<string,int> tree;//一对一映射 
    while(getline(cin,s))
    {
        tree[s]++;//数组方式 
        cnt++;
    }
    map<string,int>::iterator iter;
    for(iter=tree.begin();iter!=tree.end();iter++)
    {
        cout<<iter->first;
        printf(" %.4f\n",iter->second*100.0/cnt);
        //cout<<iter->first<<' '<<fixed<<setprecision(4)<<iter->second*100.0/num*1.0<<endl;
    }
    return 0;
}

相关文章:

  • 2022-03-07
  • 2021-11-13
  • 2022-12-23
  • 2022-12-23
  • 2022-03-03
  • 2021-06-19
  • 2022-12-23
  • 2021-09-03
猜你喜欢
  • 2022-12-23
  • 2021-06-22
  • 2021-06-10
  • 2022-12-23
  • 2021-07-31
相关资源
相似解决方案