//3*3矩阵转置,行列互换
//设两个矩阵,一个为空,利用循环
#include<stdio.h>
void convert(int a[][3])
{
int i, j, flag;
int a1[3][3] = { 0 };
for (i = 0; i < 3; i++)
for(j= 0; j < 3; j++)
a1[j][i] = a[i][j];
for (i = 0; i < 3; i++)
for (j = 0, flag = 1; j < 3; j++, flag++)
{
printf("%d", a1[i][j]);
if (flag % 3 == 0)
printf("\n");
}
}
int main()
{
int a[3][3] = { {1,8,9},{7,3,4},{3,4,5} };
convert(a);
return 0;
}
04-11
1090
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
10-29
2041
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)