/* source by gnedic@jagor & kreator@fly transpose MxN matrix around march, 1997 */ #include #include /* customizable section ;) */ #define M 5 #define N 8 int *polje; void transp (int a, int b) { int pos, tmp=*(polje+a*N+b); if ((a<(M-1)) || (b<(N-1))) pos=a*N+b+1, transp(pos/N,pos%N); /* possible is also: transp(b==(N-1)?a+1:a,b==(N-1)?0:b+1); */ *(polje+b*M+a)=tmp; } int main(void) { int i, j; polje=(int *)malloc(M*N*sizeof(int)); if (polje==NULL) exit(EXIT_FAILURE); for (i=0; i