Programming/코딩 문제 풀이
★2020/04/18 코딩 문제 연습 (7단계 / 백준 1157) C++
갓비니
2020. 4. 19. 23:02
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
36
37
38
39
40
41
|
#iclude <iostream>
#include<string>
using namespace std;
int main() {
string word;
int a[27] = { 0 };
int max = 0;
int index;
int count = 0;
cin >> word;
if (word[i] >= 97) {
word[i] = word[i] - 32;
}
a[word[i] - 65]++;
}
for (int i = 0; i<26; i++) {
if (max < a[i]) {
max = a[i];
index = i;
}
}
for (int i = 0; i<26; i++) {
if (i != index) {
if (max == a[i]) count++;
}
}
if (count != 0) cout << "?\n";
else cout << (char)(index + 65) << "\n";
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|