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 |
'프로그래밍 > 백준' 카테고리의 다른 글
2908 상수 (0) | 2018.02.08 |
---|---|
1316 그룹 단어 체커 (0) | 2017.10.20 |
2675 문자열 반복 (0) | 2017.10.15 |
10809 알파벳 찾기 (0) | 2017.10.15 |
11654 아스키 코드 (0) | 2017.10.15 |