Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define fto(i, l, r) for (int i=l; i<=r; ++i)
- using namespace std;
- string s;
- int test, all;
- map <string, int> trees;
- int main () {
- #ifndef ONLINE_JUDGE
- freopen("uva10226.inp", "r", stdin);
- #endif // OLINE_JUDGE
- scanf("%d", &test);
- getline(cin, s); getline(cin, s);
- while (test--)
- {
- trees.clear(); all = 0;
- while (1)
- {
- getline(cin, s);
- if (s.length() == 0) break; //cout << s << " ";
- ++all; //cout << all;
- if (!trees[s]) trees[s] = 1; else ++trees[s];
- }
- for (map <string, int> :: iterator it = trees.begin(); it != trees.end(); it++)
- {
- float tmp = (float) (*it).second / all * 100;
- cout << (*it).first;
- printf(" %.4f\n", tmp);
- }
- if (test > 0) printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment