본문 바로가기
PS/BOJ

[백준] 2577. 숫자의 개수(c++)

by backend 개발자 지망생 2025. 1. 15.

https://www.acmicpc.net/problem/2577

숫자의 개수를 인덱스에 저장해주는 문제였다.

 


#include<iostream>
#include <cstdio>
#include <algorithm> 
#include <vector>
#include <string>
#include <map>
#include <limits.h>
#include <queue>
#include <set>
#include <math.h>
#include <stack>

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int a, b, c;

	int result = 1;

	int ans[11] = { 0 };

	cin >> a >> b >> c;

	result = a * b * c;

	while(result > 0){
		ans[result % 10]++;

		result /= 10;
	}

	for (int i = 0; i < 10; i++) {
		cout << ans[i] << '\n';
	}

	return 0;
}

'PS > BOJ' 카테고리의 다른 글

[백준] 3273. 두 수의 합(c++)  (0) 2025.01.16
[백준] 1475. 방 번호(c++)  (0) 2025.01.15
[백준] 10808. 알파벳 개수(c++)  (0) 2025.01.13
[백준] 23842. 성냥개비(c++)  (0) 2024.12.27
[백준] 3018. 캠프파이어(c++)  (0) 2024.12.25