import sys
n=int(sys.stdin.readline())
for i in range(n,0,-1):
print(i)
range(n,0,-1)을 이용한 for문은 n부터 0+1=1까지 1씩 줄어들며 print 시키는 구문이다.
문제 : https://www.acmicpc.net/problem/2742
2742번: 기찍 N
자연수 N이 주어졌을 때, N부터 1까지 한 줄에 하나씩 출력하는 프로그램을 작성하시오.
www.acmicpc.net
'Baekjoon > python' 카테고리의 다른 글
[백준 11022번] A+B - 8 (0) | 2022.04.21 |
---|---|
[백준 11021번] A+B - 7 (0) | 2022.04.21 |
[백준 2741번] N 찍기 (0) | 2022.04.21 |
[백준 15552번] 빠른 A+B (0) | 2022.04.20 |
[백준 8393번] 합 (0) | 2022.04.20 |