본문 바로가기

BOJ

[백준] 2577번 숫자의 개수 c++

#include <iostream>
#include <vector>

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a, b, c;
    int total;
    int num;
    int arr[10] = { 0, };
    vector <int> v;
    cin >> a >> b >> c;
    total = a * b * c;
    while (total > 0) {
        num = total % 10;
        v.push_back(num);
        total /= 10;
    }

    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < 10; j++) {
            if (v[i] == j) {
                arr[j] += 1;
            }
        }
    }

    for (int n : arr)
        cout << n << "\n";
    return 0;
        
}

'BOJ' 카테고리의 다른 글

[백준] 2309번 일곱 난쟁이 c++  (0) 2020.04.20
[백준] 10804번 카드 역배치 c++  (0) 2020.04.19
[백준] 1267번 핸드폰요금 c++  (0) 2020.04.19
[백준] 2576번 홀수 c++  (0) 2020.04.19
[백준] 2480번 주사위 세개 c++  (0) 2020.04.19