알고리즘/백준(BOJ)

백준 - 10808 알파벳 개수

시나모온 2020. 8. 28. 20:49

문제 링크입니다 : https://www.acmicpc.net/problem/10808

 

10808번: 알파벳 개수

단어에 포함되어 있는 a의 개수, b의 개수, …, z의 개수를 공백으로 구분해서 출력한다.

www.acmicpc.net

 

문자열

 

 

 

 

 

 

#include <iostream>
#include <vector>

using namespace std;

int main() {
    string str;
    vector<int> alphaCnt(26, 0);

    cin >> str;

    for(int i = 0; i < str.size(); i++) {
        alphaCnt[str[i] - 'a']++;
    }

    for(int i = 0; i < 26; i++) {
        cout << alphaCnt[i] << ' ';
    }
    

    return 0;
}

 

 

 

개발 환경 : vscode

지적, 조언, 질문 환영입니다! 댓글 남겨주세요~