๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
SWEA

[SWEA] 1545. ๊ฑฐ๊พธ๋กœ ์ถœ๋ ฅํ•ด ๋ณด์•„์š”

by JulesJ 2022. 5. 24.
728x90

1545. ๊ฑฐ๊พธ๋กœ ์ถœ๋ ฅํ•ด ๋ณด์•„์š” - D1

 

D1๋ ˆ๋ฒจ ๋งˆ์ง€๋ง‰ ๋ฌธ์ œ์ธ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค..!

 

์ž…๋ ฅ๋œ ์ˆซ์ž N์„ N๋ถ€ํ„ฐ -1ํ•˜๋ฉฐ ๊ฑฐ๊พธ๋กœ ์ถœ๋ ฅํ•ด, 0๊นŒ์ง€ ์ถœ๋ ฅํ•ด๋‚ด๋Š” ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค.

 

for๋ฌธ์„ ์ด์šฉํ•˜๋Š”๋ฐ i๋ฅผ N๋ถ€ํ„ฐ ํ•˜๊ณ  i--ํ•˜๋ฉด์„œ i๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ๊ตฌํ˜„ํ–ˆ์Šต๋‹ˆ๋‹ค.

 

import java.util.Scanner;
import java.io.FileInputStream;

class Solution
{
	public static void main(String args[]) throws Exception
	{
	
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
        
		for(int i = N; i >= 0; i--)
		{
			System.out.print(i+" ");
		}
	}
}

 

 

๋ ๐Ÿง

๋Œ“๊ธ€