int* m = new int [d1*d2];
ptr1 = m;
ptr2 = m + (d2*(d1-1));
if ( *ptr1 != *ptr2){
temp = ptr2;
ptr2 = ptr1;
ptr1 = temp;
}
ptr1 +=d2;
ptr2 -= d2;
In order to do
From
4 1
3 7
5 2
To
5 2
3 7
4 1
This is what i've came up with so far which is pretty much nothing. I'm having problems with finding what kind of a loop would fit in.
std::swap(*ptr1, *ptr2). That makes it far clearer what you are trying to do.