Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n;
- map<char,int>mp;
- map<char,int> :: iterator it;
- cin>>n;
- cin.ignore();
- string s,s1="";
- while(n--){
- getline(cin,s);
- for(int i=0 ; i<s.size() ; i++){
- if(isalpha(s[i])){
- s1+=toupper(s[i]);
- }
- }
- }
- for(int i=0 ; i<s1.size() ; i++){
- mp[s1[i]]++;
- }
- multimap<int, char, greater <int> > mp2;
- multimap<int, char, greater <int> > :: const_iterator it1;
- for(it=mp.begin() ; it!=mp.end() ; it++){
- mp2.insert(make_pair(it->second , it->first));
- }
- for(it1=mp2.begin() ; it1!=mp2.end() ; it1++){
- cout<<it1->second <<" " <<it1->first <<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment