Guest User

Untitled

a guest
Jun 23rd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <map>
  4. #include <sstream>
  5. using namespace std;
  6. int main ()
  7. {
  8.     string x; int xs ,n;
  9.     freopen("myDearInput.in", "r", stdin);
  10.     while (cin >> x)
  11.     {
  12.         xs=x.size();
  13.         map <int ,int > m;
  14.         map <int , int>d;
  15.         map <int , int >::iterator it;
  16.         for (int i=0 ; i<xs ; i++)
  17.         {
  18.         n=x[i];
  19.         if ( m.find(n) != m.end() )
  20.         m[n]++;
  21.         else
  22.             m[n]=1;
  23.         }
  24.         for (it=m.begin() ;it !=m.end() ;it++)
  25.         {
  26.             d[(*it).second]=(*it).first;
  27.         }
  28.  
  29.         for (it=d.begin() ;it !=d.end() ;it++)
  30.         {
  31.             cout<<(*it).second <<" " << (*it).first <<endl;
  32.         }
  33.         cout <<endl ;
  34.  
  35.     }
  36.     return 0;
  37. }
Add Comment
Please, Sign In to add comment