[BOJ] 2588번 곱셈

5881 단어 bojboj

백준#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);
    }
}

좋은 웹페이지 즐겨찾기