백준 10808번

상인·2023년 1월 30일
0

문제-https://www.acmicpc.net/problem/10808
카운팅starr 맵 또는 배열~

#include <bits/stdc++.h>
using namespace std;
string str;
int cnt[30];
int main(){
	cin>>str;
	for(char a:str){
		cnt[a-'a']++;
	}
	for(int i=0;i<26;i++){
		cout<<cnt[i]<<" ";
	}
	return 0;
}

해설
string으로 str에 단어를 받아서 영어 알파뱃이 맵핑 되어있는 아스키 코드를 이용해서 풂
'A'=65 'a'=97 에 맵핑

profile
상상그이상인

0개의 댓글