2 条题解

  • 2
    @ 2023-10-10 21:28:16
    #include<stdio.h>
    int main()
    {
    	int T,max,i;
    	char s[1011];
    	scanf("%d",&T);
    	while(T--)
    	{
    		scanf("%s",s);	
    		int a[26]={0};  //数组代表26字母序号
    		for(i=0;s[i]!='\0';i++)
    			a[s[i]-'a']++;  //字符串中s[i]字母对应序号自增
    		max=0;
    		for(i=1;i<26;i++)  //max作为下标,最大值的下标
    			if(a[i]>a[max])
    				max=i;
    			printf("%c\n",max+'a');  //下标加‘a’还原该字母
    	}
    	return 0;
    }
    
    • @ 2023-11-18 20:24:44

      不愧是五条悟

信息

ID
186
时间
3000ms
内存
128MiB
难度
4
标签
(无)
递交数
429
已通过
192
上传者