프로그래밍/백준

1157 단어 공부

게으른구름 2017. 10. 20. 09:53
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.util.*;
 
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String get = sc.next();
        get = get.toUpperCase();
 
        int[] count = new int[26];
        int max = 0;
        int max_number = 0;
        int count2 = 1;
 
        for(int i=0; i<get.length(); i++) {
            count[get.charAt(i)-'A']++;
        }
 
        for(int i=0; i<26; i++) {
            if(max < count[i]) {
                max = count[i];
                max_number = i;
                count2 = 1;
            }
            else if(max == count[i]) {
                count2++;
            }
        }
 
        if(count2 > 1) {
            System.out.println('?');
        }
        else
            System.out.println((char)(max_number+65));
    }
}
cs