Previous Next
0 / 18
Module DEMO-32-91DEMO-C-32

Reverse Number Rectangle

DEMO-C-32 • Programming in C

Browser-only practice

Problem Statement

Write a program that reads two integers R and C from standard input, representing the number of rows and columns respectively. Your task is to print a rectangle of numbers with R rows and C columns, where each row contains the numbers from C down to 1 in descending order. Each number should be separated by a space.

For example, if R=3 and C=2, the output should be:

2 1

2 1

2 1

If R=5 and C=3, the output should be:

3 2 1

3 2 1

3 2 1

3 2 1

3 2 1


Note no spaces at the end of each line in the output

Constraints

The values of R and C are guaranteed to be between 1 and 10 inclusive.

Input Format

The input consists of a single line containing two space-separated integers R and C (1 ≤ R, C ≤ 10).

Output Format

Print R lines, each containing C space-separated integers in descending order from C to 1.

Sample Testcases

Submit runs every public testcase in this browser. Results and code never leave this device.

Sample #1
Public sample
3 2
2 1
2 1
2 1
Basic case with 3 rows and 2 columns
Sample #2
Public sample
1 5
5 4 3 2 1
Single row with multiple columns
Sample #3
Public sample
5 3
3 2 1
3 2 1
3 2 1
3 2 1
3 2 1
Example case with 5 rows and 3 columns
Sample #4
Public sample
4 1
1
1
1
1
Multiple rows with single column
Sample #5
Public sample
7 4
4 3 2 1
4 3 2 1
4 3 2 1
4 3 2 1
4 3 2 1
4 3 2 1
4 3 2 1
Medium case with 7 rows and 4 columns

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
Editor settings