알고리즘/백준 BOJ
[ BOJ/C# ] 1159 농구 경기
왹져박사
2023. 8. 27. 23:59
https://www.acmicpc.net/problem/1159
1159번: 농구 경기
상근이는 농구의 세계에서 점차 영향력을 넓혀가고 있다. 처음에 그는 농구 경기를 좋아하는 사람이었다. 농구에 대한 열정은 그를 막을 수 없었고, 결국 상근이는 농구장을 청소하는 일을 시작
www.acmicpc.net
알파벳의 아스키코드를 이용하였다.
using System;
using System.Text;
namespace _1159
{
class Program
{
static void Main()
{
StreamReader sr = new StreamReader(Console.OpenStandardInput());
StreamWriter sw = new StreamWriter(Console.OpenStandardOutput());
StringBuilder sb = new StringBuilder();
int n = int.Parse(sr.ReadLine());
int[] alphabets = new int[26];
for(int i = 0; i < n; i++)
{
string str = sr.ReadLine();
int name = str[0] - 97;
alphabets[name]++;
}
for(int i = 0; i < alphabets.Length; i++)
{
if ((int)alphabets.GetValue(i) >= 5) sb.Append((char)(i + 97));
}
if (sb.Length == 0) sb.Append("PREDAJA");
sw.WriteLine(sb);
sr.Close();
sw.Flush();
sw.Close();
}
}
}

