[BOJ] 2588번 곱셈

나르·2021년 1월 10일
0

알고리즘

목록 보기
7/15

백준#2588 곱셈
https://www.acmicpc.net/problem/2588

코드 - Python

a= int(input())
b= int(input())
fst = a*(b%10)
snd = a*((b//10)%10)
lst = a*(b//100)
print(fst,snd,lst,a*b,sep="\n")

코드 - Java

import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a,b,fst,snd,lst;
        a = sc.nextInt();
        b = sc.nextInt();
        fst = a*(b%10);
        snd = a*((b/10)%10);
        lst = a*(b/100);
        System.out.println(fst+"\n"+snd+"\n"+lst+"\n"+a*b);
    }
}
profile
💻 + ☕ = </>

0개의 댓글