문제접근![](data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==)
•
배열에 0번 인덱스부터 25번째까지 알파벳에 해당하는 배열 cnt 선언
•
입력 받은 문자열을 순회하면서 인덱스에 맞게 증감연산
놓쳤던 부분![](data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==)
코드![](data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==)
2024 KB
0 ms
#include <iostream>
#include <string>
using namespace std;
int main(void)
{
string input;
int cnt[26] = {0,};
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> input;
for (unsigned int i = 0; i < input.size(); i++)
cnt[input[i] - 'a']++;
for (int i = 0; i < 26; i++)
cout << cnt[i] << " ";
return (0);
}
C++
복사