Algorithm

[๋ฐฑ์ค€ 10808] ์•ŒํŒŒ๋ฒณ ๊ฐœ์ˆ˜

osean 2023. 3. 28. 21:17

๋ฌธ์ œ

 

10808๋ฒˆ: ์•ŒํŒŒ๋ฒณ ๊ฐœ์ˆ˜

๋‹จ์–ด์— ํฌํ•จ๋˜์–ด ์žˆ๋Š” a์˜ ๊ฐœ์ˆ˜, b์˜ ๊ฐœ์ˆ˜, …, z์˜ ๊ฐœ์ˆ˜๋ฅผ ๊ณต๋ฐฑ์œผ๋กœ ๊ตฌ๋ถ„ํ•ด์„œ ์ถœ๋ ฅํ•œ๋‹ค.

www.acmicpc.net

ํ’€์ด

#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;
}