알고리즘/SWEA 문제풀이

SWEA 1545 - D1) 거꾸로 출력해 보아요.

당글공주 2020. 7. 22. 05:53

https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV2gbY0qAAQBBAS0&categoryId=AV2gbY0qAAQBBAS0&categoryType=CODE

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

주어진 숫자부터 0까지 순서대로 찍어보세요

아래는 입력된 숫자가 N일 때 거꾸로 출력하는 예시입니다

N N-1 N-2 .... 0

 

반복문 이용하면 간단 해결!!

 

input : 8

output: 8 7 6 5 4 3 2 1 0

 

class Solution
{
     public static void main(String args[]) throws Exception
     {

          Scanner sc = new Scanner(System.in);

          int T;
          T=sc.nextInt();

          for(int i=T;i>=0;i--)System.out.print(i+" ");

     }

}