백준 1157

Oak_Cassia·2022년 3월 16일

백준 1157

#include<iostream>
using namespace std;

char Toupper(char a)
{
	if (a < 'a')
		return a - 'A';
	else
		return a - 'a';
}

int main()
{
	char* arr = new char[1000000];
	int result[26] = { 0 };
	cin >> arr;
	int cnt=0;
	while (*(arr + cnt))
	{
		result[Toupper(*(arr + cnt))]++;
		cnt++;
	}

	int max = 0;

	bool same = 0;
	for (int i = 1; i < 26; i++)
	{
		
		if (result[i] == result[max])
		{
			same = 1;
		}

		if (result[i] > result[max])
		{
			max = i;
			same = 0;
		}
		
	}

	if (same)
		cout << '?';
	else
		cout << static_cast<char>(max+'A');

	delete[] arr;
	}
profile
https://velog.io/@oak_cassia/A-Game-Developers-Vision

0개의 댓글