Advertisement
juanjo12x

UVA_10226_Hardwood_Species

Aug 11th, 2014
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <algorithm>
  4. #include <cstring>
  5. #include <string>
  6. #include <cctype>
  7. #include <stack>
  8. #include <queue>
  9. #include <list>
  10. #include <vector>
  11. #include <map>
  12. #include <set>
  13. #include <sstream>
  14. #include <stdlib.h>
  15. #include <cmath>
  16. #define LL unsigned long long
  17. using namespace std;
  18. int t;char line[35];
  19. int main() {
  20.     scanf("%d\n\n",&t);vector<string> v;
  21.     map<string,int> mp;int total;
  22.     while(t--){
  23.         total=0;
  24.       while(gets(line)){
  25.         if(strlen(line)==0) break;
  26.         if (mp.count(string(line)) == 0) {
  27.                mp[string(line)] = 1;
  28.             } else
  29.                 mp[string(line)] = mp[string(line)] + 1;
  30.  
  31.             total++;
  32.       }
  33.       map<string, int>::iterator it;
  34.         for (it = mp.begin(); it != mp.end(); it++) {
  35.             printf("%s %.4lf\n", (*it).first.data(),
  36.                     (double) (*it).second / (double) total * 100.0);
  37.         }
  38.         if (t > 0){
  39.             printf("\n");
  40.             mp.clear();
  41.         }
  42.     }
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement