728x90
반응형
2577번 숫자의 개수
문제 풀이
#include <iostream>
#include <string.h>
using namespace std;
void fast_io(void)
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
int main(void)
{
fast_io();
int a, b, c, i = 0;
int num[10] = {
0,
};
cin >> a >> b >> c;
string str = to_string(a * b * c);
for (char c : str)
{
num[c - '0']++;
}
for (int n : num)
{
cout << n << "\n";
}
}
for(char c:str)을 사용하니까 이전에 시도하려던 것보다 비교적 깔끔하게 됐다.
728x90
반응형
'자라는 개발자 > 문제풀이' 카테고리의 다른 글
백준 C++ 17219번 비밀번호 찾기 (8) | 2022.01.04 |
---|---|
백준 c++ 1620 나는야 포켓몬 마스터 이다솜 (1) | 2022.01.02 |
백준 C++ 1764번 듣보잡 (1) | 2021.12.26 |
백준 C/C++ 11050번 이항 계수 1 (0) | 2021.12.23 |
백준 C++ 11651번 좌표정렬하기 2 (0) | 2021.12.22 |