Advertisement
kokokozhina

609

Dec 14th, 2015
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include <iostream>
  2. #include <map>
  3. #include <string>
  4. #include <fstream>
  5. #include <stdio.h>
  6. #include <set>
  7.  
  8. using namespace std;
  9.  
  10. int main()
  11. {
  12.     #ifdef _DEBUG
  13.         freopen("in.txt", "r", stdin);
  14.         freopen("out.txt", "w", stdout);
  15.     #endif
  16.  
  17.     map<string, int> bank;
  18.     string word;
  19.     while(cin >> word)
  20.     {
  21.         ++bank[word];
  22.     }
  23.  
  24.     set<int> diff;
  25.     diff.insert(0);
  26.     for(auto it = bank.begin(); it != bank.end(); it++)
  27.     {
  28.         diff.insert(it->second);
  29.     }
  30.  
  31.  
  32.     int counter = 0;
  33.     set<int>::iterator it_diff = diff.end();
  34.     it_diff--;
  35.     while(counter < 10)
  36.     {
  37.         for(auto it = bank.begin(); it != bank.end(); it++)
  38.         {
  39.             if (it->second == (*it_diff))
  40.             {
  41.                 cout << it->first << " " << it->second << endl;
  42.                 counter++;
  43.             }
  44.             if (counter == 10)
  45.                 return 0;
  46.         }
  47.         it_diff--;
  48.     }
  49.  
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement