[백준] 10808번 : 알파벳 개수
2021. 1. 19. 20:31ㆍAlgorithm/백준
10808번: 알파벳 개수
단어에 포함되어 있는 a의 개수, b의 개수, …, z의 개수를 공백으로 구분해서 출력한다.
www.acmicpc.net
#include <iostream>
#include<vector>
#include<string>
using namespace std;
void solution(string s) {
int alpha[26] = { 0 };
for (int i = 0;i < s.length();i++) {
int idx = s[i]-97;
alpha[idx]++;
}
for (int i = 0;i <26;i++) {
cout << alpha[i] << ' ';
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string s = "";
cin >> s;
solution(s);
}
'Algorithm > 백준' 카테고리의 다른 글
[ 백준] 10820번 : 문자열 분석 (0) | 2021.01.19 |
---|---|
[백준] 10809번: 알파벳 찾기 (0) | 2021.01.19 |
[백준] 10866번: 덱 (0) | 2021.01.19 |
[백준] 10845번 : 큐 (0) | 2021.01.19 |
[백준] 1260번 : DFS와 BFS (0) | 2021.01.19 |