南洋理工OJ 241题 字母统计

http://acm.nyist.net/JudgeOnline/problem.php?pid=241

 

我的 用时36

 
#include
#include 
int main()
{
	int num,len,n,k,res,tmp;
	char c[1011];
	int l[1011]={0};
	scanf("%d",&num);
	getchar();
	while(num--)
	{
		gets(c);
		len=strlen(c);
		for(n=0;ntmp)
			{
				tmp=l[n];
				res=n;
			}

			
		}
		printf("%c\n",c[res]);
		for(n=0;n


 

用时0的

 
#include
#include 
int main()
{
    int u,x[26],m;
    scanf("%d",&u);
    getchar();
    while(u--)
    {
        memset(x,0,sizeof(x));
        char c=getchar();
        while(c!='\n')
        {
            x[c-'a']++;
            c=getchar();
        }
        m=0;
        for(int i=1;i<26;i++)
        if(x[i]>x[m]) m=i;
        printf("%c\n",m+'a');
    }
    return 0;
}
        


 

你可能感兴趣的:(南洋理工OJ 241题 字母统计)