#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
using namespace std;
const int N = 30 + 10;
int main()
{
int n;
string tree;
map<string, int> treeMap;
set<string> treeSet;
int cnt;
char tmp[N];
#ifndef ONLINE_JUDGE
//ifstream cin("d:\\OJ\\uva_in.txt");
freopen("d:\\OJ\\uva_in.txt", "r", stdin);
#endif
//cin >> n;
scanf("%d", &n);
//getline(cin, tree);
gets(tmp);
//getline(cin, tree);
gets(tmp);
while (n--) {
treeMap.clear();
treeSet.clear();
cnt = 0;
while (gets(tmp)/*getline(cin, tree)*/ != NULL) {
//cout << "tree:" << tree << endl;
tree = tmp;
//printf("tmp=%s\n", tmp);
if (tree == "")
break;
cnt++;
if (treeSet.count(tree)) {
treeMap[tree]++;
} else {
treeSet.insert(tree);
treeMap.insert(make_pair(tree, 1));
}
}
//cout.precision(4);
for (map<string, int>::const_iterator it = treeMap.begin(); it != treeMap.end(); it++) {
//cout << it->first << " " << fixed << (double)(it->second) / cnt * 100 << endl;
printf("%s %.4lf\n", it->first.c_str(), (double)(it->second) / cnt * 100);
}
if (n)
printf("\n");
//cout << endl;
}
return 0;
}
UVa10226 - Hardwood Species
最新推荐文章于 2019-03-27 11:23:13 发布