끄적끄적 코딩
article thumbnail
Published 2019. 8. 3. 01:04
[C++] 백준 2588번 곱셈 알고리즘
728x90

세 자리 수 x 세 자리 수를 곱할 때 곱셈과정을 출력하는 문제입니다.

세자리 x 1의 자리
세자리 x 10의 자리
세자리 x 100의 자리
결과값

을 출력하는 문제입니다.

 

#include <iostream>
using namespace std;

int main(int argc, char *argv[])
{
    int x, y;
    int a, b, c, d;
    
	cin >> x;
    cin >> y;
    
    a = x * (y % 10);
    cout << a << endl;
    y /= 10;
    b = x * (y % 10);
    cout << b << endl;
    y /= 10;
    c = x * y;
    cout << c << endl;
    d = (a + (b * 10 + (c * 100)));
    cout << d << endl;
    
    
    return 0;
}

검색 태그