Take 3X12 matrix and it is represented usingsingle diemensional array.
input:
0 1 2 3 4 5 6 7 8 9 10 11
12 13 14 15 16 17 18 19 20 21 22 23
24 25 26 27 28 29 30 31 32 33 34 35
Output:
24 25 26 27 28 29 30 31 32 33 34 35
12 13 14 15 16 17 18 19 20 21 22 23
0 1 2 3 4 5 6 7 8 9 10 11
#include<stdio.h>
main()
{
int tmp,index_of_max,max_value,i,j,k,m;
int a[36]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35};
int rows=3,columns=12,tsize;
tsize=rows*columns;
int temp;
j=0;
printf("\ninput\n");
for(i=0;i<tsize;i++)
{ if(j==12)
{
j=0;
printf("\n");
}
printf("%d\t",a[i]);
j++;
}
for ( k=0;k<rows/2;k++)
{
for( i = 0; i <columns; i++)
{
temp = a[(rows-(k+1)) * columns + i];
a[(rows-(k+1)) * columns + i] = a[k*columns + i];
a[k*columns + i] = temp;
}
}
j=0;
printf("\noutpu\n");
for(i=0;i<tsize;i++)
{ if(j==12)
{
j=0;
printf("\n");
}
printf("%d\t",a[i]);
j++;
}
getch();
}