Algorithm/백준알고리즘

[백준알고리즘] 반복문 6단계 - 2742번 기찍 N(JAVA)

개발자하소서 2022. 6. 15. 08:10
728x90
반응형
SMALL

📌문제

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

 
 

📌입력

첫째 줄에 100,000보다 작거나 같은 자연수 N이 주어진다.

 
 
 

📌출력

첫째 줄부터 N번째 줄 까지 차례대로 출력한다.

 

📌코드

import java.util.*;
 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);
         }
     }
 }
import java.io.*;
    public class Main{
        public static void main(String[] args)throws Exception{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            int n = Integer.parseInt(br.readLine());
            for(int i =n; i>0; i--){
                System.out.println(i);
            }
        }
    }
728x90
반응형
LIST