Published on

[백준 10808] 알파벳 개수

Authors
  • avatar
    Name
    심성헌 (SeongHeon Sim)
    Twitter

문제

백준 10808

알파벳 소문자로만 이루어진 단어 S가 주어진다. 각 알파벳이 단어에 몇 개가 포함되어 있는지 구하는 프로그램을 작성하시오.

풀이

제출한 코드

#include <bits/stdc++.h>

using namespace std;

string s;
int result['z' + 1];

int main() {
  cin >> s;

  for (char c: s) {
    result[c]++;
  }

  for (int i = 'a'; i <= 'z'; i++) {
    cout << result[i] << " ";
  }

  return 0;
}