Custom filling - 2. Snake
Problem
Write a program that fills a matrix of N
rows and M
columns with serpentine natural numbers, as shown in the example.
Input
The input string contains the numbers N
and M
separated by a space.
Imprint
The program should display the matrix filled in the specified way.
Example
# |
Input |
Output |
1 |
4 5 |
1 2 3 4 5
10 9 8 7 6
11 12 13 14 15
20 19 18 17 16
|