Cycle line by line
Problem
Shift each row of the given rectangular matrix
NxM
cyclically to the right by the number of positions equal to the row number (numbering of rows and columns starts from 0). Display the transformed matrix.
Input
The first line contains two numbers
N
and
M
(
\(0 < N,M <= 10\) span>). Next come N
lines of M
numbers in each - matrix elements (each element is no more than 100 modulo).
Imprint
Output the modified matrix. For each element in the output, allocate exactly 3 characters (familiar spaces).
Make a right shift K positions as a subroutine.
Example
# |
Input |
Output |
1 |
3 4
47 63 22 75
69 69 12 70
70 90 13 31 |
47 63 22 75
70 69 69 12
13 31 70 90
|