Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <map>
- #include <sstream>
- using namespace std;
- int main ()
- {
- string x; int xs ,n;
- freopen("myDearInput.in", "r", stdin);
- while (cin >> x)
- {
- xs=x.size();
- map <int ,int > m;
- map <int , int>d;
- map <int , int >::iterator it;
- for (int i=0 ; i<xs ; i++)
- {
- n=x[i];
- if ( m.find(n) != m.end() )
- m[n]++;
- else
- m[n]=1;
- }
- for (it=m.begin() ;it !=m.end() ;it++)
- {
- d[(*it).second]=(*it).first;
- }
- for (it=d.begin() ;it !=d.end() ;it++)
- {
- cout<<(*it).second <<" " << (*it).first <<endl;
- }
- cout <<endl ;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment