0

in working with my 2d arrays, i have to read in from an input file a char array of NxN and manipulate the matrix in various ways. i have gotten just about everything finished, except i cannot figure out the logic of shifting a row left or right, or shifting a column up or down.

i know i have to temporarily store the last element in a row or column, and then i get stuck on figuring out moving an element from there. i have this for trying to shift a row right that the user specifies. this part here ends up reversing the elements of the row instead of shifting them. n is the size of an NxN matrix.

```
for(int i=0; i<n/2; i++)
{
temp = matrix[row][n-i-1];
matrix[row][n-i-1] = matrix[row][i];
matrix[row][i] = temp;
}
```

*Edited 3 Years Ago by mike_2000_17*: Fixed formatting