#include<stdio.h>
#include<string.h>
int main()
{
char str[10000],m,n,c,x,ch;
int val[10000]={0},i,len,j,k,l1,temp,l2,i4,large,j4,df;
scanf("%d",&n);
scanf("%c",&c);
for(i=1;i<=n;i++)
{
gets(str);
len=strlen(str);
for(j=0;j<len;j++)
{ x=str[j];
if((x>='a')&&(x<='z'))
{
for(k=0;k<len;k++)
{
if(x==str[k])
{
val[x-32]=val[x-32]+1;
str[k]='0';
}
}
}
else if ((x>='A')&&(x<='Z'))
{
for(k=0;k<len;k++)
{
if(x==str[k])
{
val[x]=val[x]+1;
str[k]='0';
}
}
}
}
}
large=1;
while(large>0)
{ large=0;
for(i4=65;i4<=90;i4++)
{
if((val[i4]>large)&&(val[i4]!=0))
{
large=val[i4];
df=i4;
}
}
if(large!=0)
printf("%c %d\n",df,large);
val[df]=-1;
}
return 0;
}
#include<string.h>
int main()
{
char str[10000],m,n,c,x,ch;
int val[10000]={0},i,len,j,k,l1,temp,l2,i4,large,j4,df;
scanf("%d",&n);
scanf("%c",&c);
for(i=1;i<=n;i++)
{
gets(str);
len=strlen(str);
for(j=0;j<len;j++)
{ x=str[j];
if((x>='a')&&(x<='z'))
{
for(k=0;k<len;k++)
{
if(x==str[k])
{
val[x-32]=val[x-32]+1;
str[k]='0';
}
}
}
else if ((x>='A')&&(x<='Z'))
{
for(k=0;k<len;k++)
{
if(x==str[k])
{
val[x]=val[x]+1;
str[k]='0';
}
}
}
}
}
large=1;
while(large>0)
{ large=0;
for(i4=65;i4<=90;i4++)
{
if((val[i4]>large)&&(val[i4]!=0))
{
large=val[i4];
df=i4;
}
}
if(large!=0)
printf("%c %d\n",df,large);
val[df]=-1;
}
return 0;
}
No comments:
Post a Comment