#CCBCHMOT0000001. Đếm từ n về 1 bằng while (Countdown with While)
Đếm từ n về 1 bằng while (Countdown with While)
Countdown with While
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given a nonnegative integer n, print n, n-1, ..., 1 in descending order, one integer per line. For n=0, produce no output.
Input
One integer n.
Output
Print n down to 1, one per line; print nothing when n=0.
Subtasks
- Subtask 1 (20%): 0 <= n <= 5.
- Subtask 2 (30%): 0 <= n <= 100.
- Subtask 3 (50%): 0 <= n <= 1000.
Examples
Example 1
Input
3
Output
3
2
1
Explanation
Starting from 3, print 3, 2, then 1 while decrementing after each print; 0 fails the loop condition.
Example 2
Input
0
Output
Explanation
The condition is false before the first iteration, so nothing is printed.