Go Down

Topic: How to manipulate a matrix. (Read 423 times) previous topic - next topic

Manny

Lets say I have..
int matrix[5][5]={{0,0,0,0,0},{1,1,1,1,1},{2,2,2,2,2},{3,3,3,3,3},{4,4,4,4,4}};
How do I manipulate this matrix to make it look like...
{{0,0,0,0,0},{0,0,0,0,0},{1,1,1,1,1},{2,2,2,2,2},{3,3,3,3,3}}
then
{{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0},{1,1,1,1,1},{2,2,2,2,2}}
and so on.....
What I basically want to do is shift every row down by one or up by one.
Any suggestions???

johnwasser

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

westfw

What John meant is that C has not particular magic functions to do any matrix manipulation; you have to do it yourself, one element at a time...

AWOL

Quote
you have to do it yourself, one element at a time...

Or a row ata time, using memcpy
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Go Up