Challenge: Number Staircase

Lab C Intermediate 20 points

Read n and print a staircase of numbers: row r prints the numbers 1 to r, separated by spaces.

Input

One integer n (1 ≤ n ≤ 9).

Output

n lines.

Example

Input

4

Output

1
1 2
1 2 3
1 2 3 4
Sample input available Sample output available
Editor
C

Hints

Use one loop for the rows and one inside it for the numbers.

The inner loop goes from 1 to row.

Solution explanation

The outer loop picks the row; the inner loop prints that row's numbers, with a space before every number except the first.

Show solution
#include <stdio.h>

int main() {
    int n;
    scanf("%d", &n);
    for (int row = 1; row <= n; row++) {
        for (int i = 1; i <= row; i++) {
            if (i > 1) {
                printf(" ");
            }
            printf("%d", i);
        }
        printf("\n");
    }
    return 0;
}
Output
Answer
HOME LABS COMMUNITY DASHBOARD