Quick actions

cmd+k|ctrl+k

Navigation

Languages

13. 가장 많이 사용된 자릿수

Snippet info

Language

C

Visibility

public

Author

kim112mgxld

Created

2020-09-23T02:25:57Z

Updated

2020-10-06T15:54:42Z

#include <stdio.h>
#include <stdlib.h>

int main(void) {
    int max = -1000;
    int res = 0;
    int count[10] = {0};
    char checkNumber[101];
    
    scanf("%s", checkNumber);
    
    for (int i = 0; checkNumber[i] != '\0'; i++) {
        count[checkNumber[i] - 48]++;
    }
    
    for (int i = 0; i < 10; i++) {
        if (max < count[i]) {
            max = count[i];
            res = i;
        } else if (max == count[i]) {
            res = i;
        }
    }
    
    printf("%d\n", res);
    
    return 0;
}
INFO