#include <bits/stdc++.h>
using namespace std;
int main()
{
map<string, int> Tree;
string tree;
// 读取所有输入行
while (getline(cin, tree)) {
if (tree.empty())break;
Tree[tree]++;
}
long long sum = 0;
// 计算树的总数量
for (auto pair : Tree) {
sum += pair.second;
}
// 输出每棵树的名称和百分比
for (auto pair : Tree) {
cout << pair.first << " " << fixed << setprecision(4) ;
printf(" % .4f", pair.second / (double)sum * 100);
cout << endl;
}
return 0;
}
POJ-2418
最新推荐文章于 2024-09-13 13:21:04 发布