#include <iostream>
#include <cstdio>
#include <cstring>
#include<map>
#include<algorithm>
//#include<bits/stdc++.h>
using namespace std;
int main()
{
int mp[26],str[26],i,j;
for(i=0, j=65; i<26; i++,j++)
{
mp[i]=0;
str[i]=j;
}
int test,c=0;
char ch;
scanf("%d",&test);
getchar();
while(ch=getchar())
{
if(ch=='\n')
{
c++;
}
if(c==test)
{
break;
}
if(ch=='A'||ch=='a')
{
mp[0]++;
}
else if(ch=='B'||ch=='b')
{
mp[1]++;
}
else if(ch=='C'||ch=='c')
{
mp[2]++;
}
else if(ch=='D'||ch=='d')
{
mp[3]++;
}
else if(ch=='E'||ch=='e')
{
mp[4]++;
}
else if(ch=='F'||ch=='f')
{
mp[5]++;
}
else if(ch=='G'||ch=='g')
{
mp[6]++;
}
else if(ch=='H'||ch=='h')
{
mp[7]++;
}
else if(ch=='I'||ch=='i')
{
mp[8]++;
}
else if(ch=='J'||ch=='j')
{
mp[9]++;
}
if(ch=='K'||ch=='k')
{
mp[10]++;
}
else if(ch=='L'||ch=='l')
{
mp[11]++;
}
else if(ch=='M'||ch=='m')
{
mp[12]++;
}
else if(ch=='N'||ch=='n')
{
mp[13]++;
}
else if(ch=='O'||ch=='o')
{
mp[14]++;
}
if(ch=='P'||ch=='p')
{
mp[15]++;
}
else if(ch=='Q'||ch=='q')
{
mp[16]++;
}
else if(ch=='R'||ch=='r')
{
mp[17]++;
}
else if(ch=='S'||ch=='s')
{
mp[18]++;
}
else if(ch=='T'||ch=='t')
{
mp[19]++;
}
else if(ch=='U'||ch=='u')
{
mp[20]++;
}
else if(ch=='V'||ch=='v')
{
mp[21]++;
}
else if(ch=='W'||ch=='w')
{
mp[22]++;
}
else if(ch=='X'||ch=='x')
{
mp[23]++;
}
else if(ch=='Y'||ch=='y')
{
mp[24]++;
}
else if(ch=='Z'||ch=='z')
{
mp[25]++;
}
}
int sw,swp;
for(i=0; i<26; i++)
{
for(j=0; j<25; j++)
{
if(mp[j]<mp[j+1])
{
swp=str[j+1];
str[j+1]=str[j];
str[j]=swp;
sw=mp[j+1];
mp[j+1]=mp[j];
mp[j]=sw;
}
}
}
for( i=0; i<26; i++)
{
if(mp[i]!=0)
{
printf("%c %d\n",str[i],mp[i]);
}
}
return 0;
}
#include <cstdio>
#include <cstring>
#include<map>
#include<algorithm>
//#include<bits/stdc++.h>
using namespace std;
int main()
{
int mp[26],str[26],i,j;
for(i=0, j=65; i<26; i++,j++)
{
mp[i]=0;
str[i]=j;
}
int test,c=0;
char ch;
scanf("%d",&test);
getchar();
while(ch=getchar())
{
if(ch=='\n')
{
c++;
}
if(c==test)
{
break;
}
if(ch=='A'||ch=='a')
{
mp[0]++;
}
else if(ch=='B'||ch=='b')
{
mp[1]++;
}
else if(ch=='C'||ch=='c')
{
mp[2]++;
}
else if(ch=='D'||ch=='d')
{
mp[3]++;
}
else if(ch=='E'||ch=='e')
{
mp[4]++;
}
else if(ch=='F'||ch=='f')
{
mp[5]++;
}
else if(ch=='G'||ch=='g')
{
mp[6]++;
}
else if(ch=='H'||ch=='h')
{
mp[7]++;
}
else if(ch=='I'||ch=='i')
{
mp[8]++;
}
else if(ch=='J'||ch=='j')
{
mp[9]++;
}
if(ch=='K'||ch=='k')
{
mp[10]++;
}
else if(ch=='L'||ch=='l')
{
mp[11]++;
}
else if(ch=='M'||ch=='m')
{
mp[12]++;
}
else if(ch=='N'||ch=='n')
{
mp[13]++;
}
else if(ch=='O'||ch=='o')
{
mp[14]++;
}
if(ch=='P'||ch=='p')
{
mp[15]++;
}
else if(ch=='Q'||ch=='q')
{
mp[16]++;
}
else if(ch=='R'||ch=='r')
{
mp[17]++;
}
else if(ch=='S'||ch=='s')
{
mp[18]++;
}
else if(ch=='T'||ch=='t')
{
mp[19]++;
}
else if(ch=='U'||ch=='u')
{
mp[20]++;
}
else if(ch=='V'||ch=='v')
{
mp[21]++;
}
else if(ch=='W'||ch=='w')
{
mp[22]++;
}
else if(ch=='X'||ch=='x')
{
mp[23]++;
}
else if(ch=='Y'||ch=='y')
{
mp[24]++;
}
else if(ch=='Z'||ch=='z')
{
mp[25]++;
}
}
int sw,swp;
for(i=0; i<26; i++)
{
for(j=0; j<25; j++)
{
if(mp[j]<mp[j+1])
{
swp=str[j+1];
str[j+1]=str[j];
str[j]=swp;
sw=mp[j+1];
mp[j+1]=mp[j];
mp[j]=sw;
}
}
}
for( i=0; i<26; i++)
{
if(mp[i]!=0)
{
printf("%c %d\n",str[i],mp[i]);
}
}
return 0;
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন