티스토리 뷰

문제

(세 자리 수) × (세 자리 수)는 다음과 같은 과정을 통하여 이루어진다.

(1)과 (2)위치에 들어갈 세 자리 자연수가 주어질 때 (3), (4), (5), (6)위치에 들어갈 값을 구하는 프로그램을 작성하시오.

입력

첫째 줄에 (1)의 위치에 들어갈 세 자리 자연수가, 둘째 줄에 (2)의 위치에 들어갈 세자리 자연수가 주어진다.

출력

첫째 줄부터 넷째 줄까지 차례대로 (3), (4), (5), (6)에 들어갈 값을 출력한다.

풀이 과정

(3) - (1)과 (2)의 일의 자리 수를 곱한 값

(4) - (1)과 (2)의 십의 자리 수를 곱한 값

(5) - (1)과 (2)의 백의 자리 수를 곱한 값

(6) - (1)과 (2)를 곱한 값

이를 차례대로 출력한다.

 

C

#include <stdio.h>

int main(void) {
    int a, b;
    scanf("%d %d", &a, &b);
    printf("%d\n", a*(b%10));
    printf("%d\n", a*((b%100)/10));
    printf("%d\n", a*(b/100));
    printf("%d\n", a*b);
    return 0;
}

C++

#include <iostream>
using namespace std;

int main(void) {
    int a, b; cin >> a >> b;
    cout << a*(b%10) << endl << a*((b%100)/10) << endl << a*(b/100) << endl << a*b;
    return 0;
}

Python

a = int(input())
b = int(input())
print(a*(b%10))
print(a*((b%100)//10))
print(a*(b//100))
print(a*b)

Java

import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(a*(b%10));
        System.out.println(a*((b%100)/10));
        System.out.println(a*(b/100));
        System.out.println(a*b);
    }
}
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/10   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함