Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <algorithm>
- #include <cstring>
- #include <string>
- #include <cctype>
- #include <stack>
- #include <queue>
- #include <list>
- #include <vector>
- #include <map>
- #include <set>
- #include <sstream>
- #include <stdlib.h>
- #include <cmath>
- #define LL unsigned long long
- using namespace std;
- int t;char line[35];
- int main() {
- scanf("%d\n\n",&t);vector<string> v;
- map<string,int> mp;int total;
- while(t--){
- total=0;
- while(gets(line)){
- if(strlen(line)==0) break;
- if (mp.count(string(line)) == 0) {
- mp[string(line)] = 1;
- } else
- mp[string(line)] = mp[string(line)] + 1;
- total++;
- }
- map<string, int>::iterator it;
- for (it = mp.begin(); it != mp.end(); it++) {
- printf("%s %.4lf\n", (*it).first.data(),
- (double) (*it).second / (double) total * 100.0);
- }
- if (t > 0){
- printf("\n");
- mp.clear();
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement