Algorithm/백준알고리즘
[백준알고리즘] 반복문 1단계 - 2739번 구구단(JAVA)
개발자하소서
2022. 6. 13. 08:17
728x90
반응형
SMALL
📌문제
N을 입력받은 뒤, 구구단 N단을 출력하는 프로그램을 작성하시오. 출력 형식에 맞춰서 출력하면 된다.
📌입력
첫째 줄에 N이 주어진다. N은 1보다 크거나 같고, 9보다 작거나 같다.
📌출력
출력형식과 같게 N*1부터 N*9까지 출력한다.

📌코드
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
for(int i=1; i<10; i++){
System.out.println(a + " * " + i + " = " + (a * i));
// 각 문자열 앞 뒤 공백 넣어주기!
}
}
}
import java.io.*;
import java.util.*;
public class Main{
public static void main(String[] args)throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int a = Integer.parseInt(br.readLine());
for (int i=1; i<10; i++){
System.out.println(a + " * " + i + " = " + (a * i));
}
}
}
728x90
반응형
LIST