사생활 보호 설정
https://gamjia.tistory.com
Updated News
Mini Rooms
답글수 [0]
What Friends Say
한마디로 표현해봐~
1촌평 관리
1157번 단어 공부
GamJia 2023. 3. 27. 09:13
단계별로 풀어보기 - 문자열 - 5단계
https://www.acmicpc.net/problem/1157
#include <iostream> using namespace std; int main() { string S; cin >> S; int max = 0, count = 0, index; int arr[26] = { 0, }; string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; for (int i = 0; i < S.length(); i++) { S.at(i) = toupper(S.at(i)); arr[S.at(i) - 'A']++; // 사용한 알파벳 개수 세기 } for (int i = 0; i < 26; i++) { if (max < arr[i]) { max = arr[i]; count = 0; index = i; } if (max == arr[i]) { count++; } } if (count > 1) { cout << "?"; } else { cout << (char)(index+'A'); } return 0; }