백준 algorithm

백준 2588 곱셈

cosmohoo 2019. 12. 20. 18:34
반응형

문제설명

곱하는 수를 10으로 나누면서 곱하고 배열에 넣어 출력하였다. 

 

#include <iostream>
using namespace std;

int main()
{
	int first, second,second2;
	cin >> first >> second;
	second2 = second;
	int arr[10];
	int cnt = 0;
	while (second != 0)
	{
	
		int tmp = second % 10;
		second = second / 10;
		arr[cnt++] = first * tmp;
	}
	arr[cnt] = first * second2;

	for (int i = 0; i <= cnt; i++)
	{
		cout << arr[i] << '\n';
	}
	return 0;
}
반응형