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

      不愧是五条悟

  • 1
    @ 2023-11-21 0:37:51
    #include<string.h>
    int num[10000],xx[10000];
    int main()
    {
    	int t;
    	scanf("%d",&t);
    	while(t--){
    		memset(num,0,sizeof num);
    		memset(xx,0,sizeof xx);
    		char a[10000];
    		int flag=0,ed;
    		scanf("%s",a);
    		int x=strlen(a);
    		for(int i=0;i<x;i++){
    			num[i]=a[i];
    			xx[num[i]]++;
    		}
    		for(int i=0;i<10000;i++){
    			if(flag<xx[i]){
    				ed=i;
    				flag=xx[i];
    			}
    		}
    		char q=ed;
    		printf("%c\n",q);
    	}
    	return 0;
    }
    
    • 1

    信息

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