자바 세자리 연산 과정

자바 세자리 연산 과정

백준알고리즘 2588

=> (1) a = 472, (2) b = 385

=>기준 값을 10으로 반복해 나눈 값을 10으로 나머지 연산을 하면 일의 자리를 얻을 수 있다.

import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int tmp = b; for (int i = 0; i < 3; i++) { tmp = (i > 0 ? tmp / 10 : b); System.out.println(a * (tmp % 10)); } System.out.println(a * b); } }

from http://zeromi.tistory.com/80 by ccl(A) rewrite - 2021-11-25 13:27:35