#t1138. 输出 1 到 n
输出 1 到 n
Output 1 to n
Problem Description
This is your first loop problem.
A loop is like running laps around a track: you tell the computer "run from lap 1 to lap ", and it repeats the same action lap after lap for you. In C++, the most basic counting loop looks like this:
for (int i = 1; i <= n; i++) {
// loop body: i will take the values 1, 2, 3, ..., n in turn
}
Read in a positive integer , and use a loop to output each of the numbers from to on its own line, so you can feel how a loop counts one by one.
Input Format
One line, a positive integer .
Output Format
There are lines in total; the -th line outputs the integer .
Sample Input
3
Sample Output
1
2
3
Constraints
For of the data, .
Hint
- After printing inside the loop body, remember to add a newline.
- If your program never stops, the judge will return TLE (Time Limit Exceeded) — check whether
i++is written correctly.