백준 1157 단어 공부
Console Programming/C# Console 2019. 11. 5. 23:49
using System;
namespace _1157
{
class Program
{
static void Main(string[] args)
{
int[] cntAlpha = new int[26];
string str = Console.ReadLine();
string str2 = str.ToUpper();
for (int i = 0; i < str2.Length; i++)
{
int j = ((int)str2[i] - 65);
cntAlpha[j]++;
}
int max = cntAlpha[0];
int mostUsed = 0;
int Duple = 0;
for (int i = 1; i < 26; i++)
{
if (max < cntAlpha[i])
{
max = cntAlpha[i];
mostUsed = i;
}
}
for (int i = 0; i < 26; i++)
{
if (max == cntAlpha[i])
{
Duple++;
}
}
if (Duple == 1)
{
Console.WriteLine((char)(mostUsed + 65));
}
else
{
Console.WriteLine("?");
}
}
}
}
'Console Programming > C# Console' 카테고리의 다른 글
백준 2292 벌집 (0) | 2019.11.07 |
---|---|
백준 1193 분수찾기 (0) | 2019.11.06 |
백준 11654 아스키 코드 (0) | 2019.11.05 |
백준 10809 알파벳 찾기 (0) | 2019.11.05 |
백준 10828 스택 (0) | 2019.11.04 |