karlangadas

Hardwood Species

Dec 22nd, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <iostream>
  2. #include <map>
  3. #include <cstdio>
  4. #include <string>
  5. #include <cstring>
  6. using namespace std;
  7.  
  8. int main() {
  9.     int ncases;
  10.     scanf("%d\n",&ncases);
  11.     while(ncases--){
  12.         map<string,int>m;
  13.         int n=0;
  14.         char s[35];
  15.         while(gets(s) && strlen(s)!=0){
  16.             m[s]++;
  17.             n++;
  18.         }
  19.         for (map<string,int>::iterator it=m.begin(); it!=m.end(); it++)
  20.             printf("%s %.4lf\n", (*it).first.data(),    (double) (*it).second / (double) n * 100.0);
  21.         if (ncases>0)
  22.             printf("\n");      
  23.     }
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment