์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ/BOJ_Java

[BOJ/Step3] 2739 : ๊ตฌ๊ตฌ๋‹จ (JAVA)

NaNaRin๐Ÿ™ƒ 2021. 1. 6. 18:05

www.acmicpc.net/problem/2739

 

2739๋ฒˆ: ๊ตฌ๊ตฌ๋‹จ

N์„ ์ž…๋ ฅ๋ฐ›์€ ๋’ค, ๊ตฌ๊ตฌ๋‹จ N๋‹จ์„ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ์ถœ๋ ฅ ํ˜•์‹์— ๋งž์ถฐ์„œ ์ถœ๋ ฅํ•˜๋ฉด ๋œ๋‹ค.

www.acmicpc.net


๋ฌธ์ œ

N์„ ์ž…๋ ฅ๋ฐ›์€ ๋’ค, ๊ตฌ๊ตฌ๋‹จ N๋‹จ์„ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ์ถœ๋ ฅ ํ˜•์‹์— ๋งž์ถฐ์„œ ์ถœ๋ ฅํ•˜๋ฉด ๋œ๋‹ค.

 

์ž…๋ ฅ

์ฒซ์งธ ์ค„์— N์ด ์ฃผ์–ด์ง„๋‹ค. N์€ 1๋ณด๋‹ค ํฌ๊ฑฐ๋‚˜ ๊ฐ™๊ณ , 9๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™๋‹ค.

 

์ถœ๋ ฅ

์ถœ๋ ฅํ˜•์‹๊ณผ ๊ฐ™๊ฒŒ N1๋ถ€ํ„ฐ N9๊นŒ์ง€ ์ถœ๋ ฅํ•œ๋‹ค.

 

์˜ˆ์ œ ์ž…๋ ฅ 1

2

 

์˜ˆ์ œ ์ถœ๋ ฅ 1

2 * 1 = 2

2 * 2 = 4

2 * 3 = 6

2 * 4 = 8

2 * 5 = 10

2 * 6 = 12

2 * 7 = 14

2 * 8 = 16

2 * 9 = 18


ํ’€์ด

 

import java.util.Scanner;

public class B2739 {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		
		for(int i = 0; i < 9; i++) {
			System.out.println(a + " * " + (i+1) + " = " + a*(i+1));
		}

	}

}