Problems with two-dimensional array

You could use two loops, if you recognize that the amount you shift the value by is a function of the inner loop index.