-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1157.cpp
More file actions
41 lines (36 loc) · 860 Bytes
/
1157.cpp
File metadata and controls
41 lines (36 loc) · 860 Bytes
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
#include <iostream>
#include <string>
using namespace std;
int main()
{
int alpha[26] = { 0, };
string str;
int max = 0;
cin >> str;
for (int i = 0; i < str.length(); i++) //alpha배열에서 알파벳 개수 세기
{
alpha[toupper(str[i]) - 'A']++;
}
int max_index = 0; //alpha 배열에서 가장 큰 값 저장
for (int i = 0; i < 26; i++)
{
if (alpha[i] > max)
{
max = alpha[i];
max_index = i;
}
}
int count = 0; //가장 큰 값을 갖는 알파벳이 중복되면 ?출력
for (int i = 0; i < 26; i++)
{
if (alpha[i] == max)
count++;
if (count >= 2)
{
cout << "?" << endl;
return 0;
}
}
cout << (char)(max_index + 65) << endl; //문자열로 변환
return 0;
}