본문 바로가기
알고리즘/백준

[백준 2742번 ː 자바(JAVA)] 기찍 N

by 그릿er 2020. 4. 17.

 

<문제>

 

자연수 N이 주어졌을 때, N부터 1까지 한 줄에 하나씩 출력하는 프로그램을 작성하시오.

 

 

 

1
2
3
4
5
6
7
8
9
10
11
12
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(int i=n; i>0; i--){
            System.out.println(i);
        }        
        
    }
}