Advertisement
Anikdip

Untitled

Aug 21st, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #include<cstdio>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. map<string,int> mp;
  9. double cnt,temp;
  10. int t;
  11. string tree;
  12. cin>>t;
  13. getchar();
  14. getchar();
  15. while(t--)
  16. {
  17.  
  18. cnt=0.0;
  19. while(1)
  20. {
  21.  
  22. getline(cin,tree);
  23. if(tree=="")
  24. {
  25.  
  26. break;
  27.  
  28. }
  29. else
  30. {
  31. cnt++;
  32. mp[tree]++;
  33. }
  34.  
  35. }
  36.  
  37. map<string,int>:: iterator it;
  38.  
  39.  
  40. for(it = mp.begin();it!=mp.end();it++)
  41. {
  42. temp = it->second;
  43. cout<<it->first<<" ";
  44. printf("%.4lf\n",(temp/cnt)*100);
  45. }
  46.  
  47. if(t>0)
  48. {
  49. cout<<endl;
  50. mp.clear();
  51. }
  52. }
  53.  
  54. return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement