>how do i rotate the array to the left
Simple enough, just think differently when you traverse the array:
Code:
#include <iostream>
using namespace std;
int main()
{
int i, j;
int a[4][4] =
{
{ 1,1,1,1 },
{ 2,2,2,2 },
{ 3,3,3,3 },
{ 4,4,4,4 },
};
cout<<"Original array: "<<endl;
for ( i = 0; i < 4; ++i ) {
for ( j = 0; j < 4; ++j )
cout<< a[i][j] <<' ';
cout.put ( '\n' );
}
cout<<"\nRotated array: "<<endl;
for ( i = 0; i < 4; ++i ) {
for ( j = 0; j < 4; ++j )
cout<< a[j][i] <<' ';
cout.put ( '\n' );
}
return 0;
}
-Prelude