#include<bits/stdc++.h>
using namespace std;
int main()
{
int a[128], b[128], i, j, k = 0, n, m;
string s;
while(getline(cin, s))
{
if(k > 0)
cout << endl;
for(i=0;i<128;i++)
a[i] = b[i] = 0;
int l = s.size();
for(i=0; i<l; i++)
{
int t = s[i];
a[t] +=1;
b[t] = t;
}
for(i=0; i<128-1; i++)
{
for(j=0; j<128-i-1; j++)
{
if(a[j] > a[j+1])
{
swap(a[j], a[j+1]);
swap(b[j], b[j+1]);
}
if(a[j] == a[j+1])
{
if(b[j] < b[j+1])
{
swap(a[j], a[j+1]);
swap(b[j], b[j+1]);
}
}
}
}
for(i=0;i<128;i++)
{
if(a[i]>0)
{
cout << b[i] << " " << a[i] << endl;
}
}
k++;
}
return 0;
}
using namespace std;
int main()
{
int a[128], b[128], i, j, k = 0, n, m;
string s;
while(getline(cin, s))
{
if(k > 0)
cout << endl;
for(i=0;i<128;i++)
a[i] = b[i] = 0;
int l = s.size();
for(i=0; i<l; i++)
{
int t = s[i];
a[t] +=1;
b[t] = t;
}
for(i=0; i<128-1; i++)
{
for(j=0; j<128-i-1; j++)
{
if(a[j] > a[j+1])
{
swap(a[j], a[j+1]);
swap(b[j], b[j+1]);
}
if(a[j] == a[j+1])
{
if(b[j] < b[j+1])
{
swap(a[j], a[j+1]);
swap(b[j], b[j+1]);
}
}
}
}
for(i=0;i<128;i++)
{
if(a[i]>0)
{
cout << b[i] << " " << a[i] << endl;
}
}
k++;
}
return 0;
}
Comments
Post a Comment