알고리즘
백준 2739 - 구구단
bysnow
2024. 2. 13. 21:55
728x90
반응형
SMALL
https://www.acmicpc.net/problem/2739
2739번: 구구단
N을 입력받은 뒤, 구구단 N단을 출력하는 프로그램을 작성하시오. 출력 형식에 맞춰서 출력하면 된다.
www.acmicpc.net
import java.util.Scanner;
public class multiplicationTable {
//input a number n, then print n times table
public void printTimesTable(){
Scanner sc = new Scanner(System.in);
int n;
//1 <= n <= 9
n = sc.nextInt();
for(int i=1; i<10; i++){
System.out.println(n + " * " + i +" = " + n*i);
}
}
}
반복문을 이용해 구구단을 출력하는 간단한 문제이다.
728x90
반응형
LIST