Algorithm
[BOJ] 10808 알파벳 개수
일등하이
2023. 1. 17. 23:26
반응형
https://www.acmicpc.net/problem/10808
10808번: 알파벳 개수
단어에 포함되어 있는 a의 개수, b의 개수, …, z의 개수를 공백으로 구분해서 출력한다.
www.acmicpc.net
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace _10808
{
class Program
{
static void Main()
{
StreamReader sr = new StreamReader(Console.OpenStandardInput());
StreamWriter sw = new StreamWriter(Console.OpenStandardOutput());
StringBuilder sb = new StringBuilder();
string str = Console.ReadLine();
int[] arr = new int[26];
for (int i = 0; i < str.Length; i++)
{
var idx = str[i] - 'a';
arr[idx]++;
}
foreach (int a in arr)
{
sb.Append(a + " ");
}
Console.WriteLine(sb.ToString());
sr.Close();
sw.Flush();
sw.Close();
}
}
}
반응형