[백준] 2588 곱셈

오규리·2023년 1월 20일
0
#include <iostream>

using namespace std;

int main() {
	int numberToMultiply, numberMultipliedBy;

	cin >> numberMultipliedBy >> numberToMultiply;

	int units, tens, hundreds;

	units = numberToMultiply % 10;
	tens = numberToMultiply / 10 % 10;
	hundreds = numberToMultiply / 100;

	int first, second, third, last;

	first = numberMultipliedBy * units;
	second = numberMultipliedBy * tens;
	third = numberMultipliedBy * hundreds;
	last = first + second * 10 + third * 100;

	cout << first << endl;
	cout << second << endl;
	cout << third << endl;
	cout << last << endl;

	return 0;
}

units, tens, hundreds를 구하는 것이 핵심

0개의 댓글