Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Forming Matrix in C Language
Forming Matrix in C Language
Square matrix transposition is relatively simple, just exchange the upper triangle or the lower triangle.

# contains "stdio.h"

void Transpose(int (*matrix)[3])

{

Internal temperature;

int i,j;

for(I = 1; I<3; I++)/* Transpose */

{

for(j = 0; J< me; j++)

{

temp = *(*(matrix+j)+I);

* (* (matrix +j)+i) = * (matrix+i)+j);

*(*(matrix+I)+j)= temp;

}

}

}

void main()

{

int a[3][3] = {{ 1,2,3},{4,5,6},{7,8,9 } };

Transpose (a);

for(int I = 0; I<3; i++)

{

for(int j = 0; j & lt3; j++)

{

printf("%d ",a[I][j]);

}

printf(" \ n ");

}

}