Rohyoohyun / C

0 stars 0 forks source link

1157 단어공부 #32

Open Rohyoohyun opened 1 month ago

Rohyoohyun commented 1 month ago
#include <stdio.h>
#include <string.h>
int main(){
    int max=0, result=0;
    char arr[1000000];
    scanf("%s", arr);

    int select = 0, cnt[26] = {0, }; 
    for(int i = 'a'; i <= 'z'; i++)
        for(int j = 0; j < strlen(arr); j++)
            if(i == arr[j])
               cnt[i-'a']++;

    for(int i = 'A'; i <= 'Z'; i++)
        for(int j = 0; j < strlen(arr); j++)
           if(i == arr[j])
               cnt[i-'A']++;

    max = cnt[0];
    for(int i = 1; i < 26; i++)
        if(max < cnt[i]){
            max = cnt[i];
            select = i;
        }

    for(int i = 0; i < 26; i++)
        if(max == cnt[i])
            result++;

    if(result > 1) printf("?");
    else printf("%c", select+'A');

    return 0;
}