Hi,
You can do one of two things:-
Your input is a[3][3]={1,2,3,4,5,6,7,8,9}
You need output {1,6,7,2,5,8,3,4,9}
1.Assuming your input is always a 2-d array a[3][3]
You can use a temporary variable say temp and rearrange the sequence
Something like
for(n=0 to 8)
{
a[0][0]=a[0][0];//Keeping 1 in the first position
temp=a[0][1];//Storing value in second position say 2
a[0][1]=a[1][2]//Now we are storing the value in position a[1][2] that is 6 in the second position
a[1][2]=temp//At this stage your array will look like this a[3][3]={1,6,3,4,5,2,7,8,9}
//Similarly you assign the value for next position
//Say you want 7 to appear in the 3rd position
/*so add a few steps and exchange array element 7 with array element 3 so you get the array a[3][3]={1,6,7,4,5,2,3,8,9} */
//proceed this way until you get the required arrangement
}
2.The other way is a more complicated code but it is shorter,I suggest you dont attempt it since it looks like you are at a beginners level