Problems
After receiving the height n and width m of a rectangle,
write a program that prints numbers from 1 to n × m in order, in an n-row, m-column rectangular shape.
<Processing Conditions>
The order of the numbers proceeds as follows: first, starting from the top row, print numbers from 1 to m from left to right.
Then move to the next row, and again print numbers increasing by 1 from left to right.
Repeat this method until the n-th row.
Input
The height n and the width m of the rectangle are given.
(The range of n and m is integers not exceeding 100.)
Output
Print the rectangular shape described above according to the height n and width m given in the input.
Separate the numbers with spaces.
Example
4 5
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
Tag
Source
JUNGOL