#include<iostream>
#include<list>
#include<string>
#include<cstring>
#include<sstream>
#include<cctype>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<stack>
#include<fstream>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<queue>
using namespace std;
#define INF (1<<29)
#define SET(a) memset(a,-1,sizeof(a))
#define ALL(a) a.begin(),a.end()
#define CLR(a) memset(a,0,sizeof(a))
#define FILL(a,v) memset(a,v,sizeof(a))
#define PB push_back
#define FOR(i,n) for(int i = 0;i<n;i++)
#define PI acos(-1.0)
#define EPS 1e-9
#define MP(a,b) make_pair(a,b)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define LL long long
#define MX 100000
#define MOD 1000000007
struct Z{
int ascii_value;
int frequenci;
bool operator < (const Z &p) const{
if(frequenci==p.frequenci)
return ascii_value>p.ascii_value;
else
return frequenci<p.frequenci;
}
};
int main()
{
LL t,kk=1,c,r,sqt,i,num;
string s;
map<int,int>used;
map<int,int>freqnci;
Z z;
while(getline(cin,s))
{
vector<Z>character;
vector<Z>:: iterator it;
used.clear();
freqnci.clear();
for(i=0;i<s.length();i++)
{
num=s[i];
used[num]=1;
freqnci[num]++;
}
for(i=32;i<128;i++)
if(used[i]==1)
{
z.ascii_value=i;
z.frequenci=freqnci[i];
character.PB(z);
}
sort(ALL(character));
c=character.size();
if(kk!=1)
cout<<endl;
for(i=0;i<c;i++)
cout<<character[i].ascii_value<<" "<<character[i].frequenci<<endl;
kk++;
}
return 0;
}
No comments:
Post a Comment