编写程序,实现矩阵(3 行、3 列)的转置(即行列转换)。
例如,若输入下面的矩阵:
100 200 300
400 500 600
700 800 900
则程序输出:
100 400 700
200 500 800
300 600 900
//
#include<stdio.h>
#include<stdlib.h>
void main()
{
int i,j;
int a[3][3];
for(i=0;i<3;i++)
for(j=0;j<3;j++)
scanf("%d",&a[i][j]);
for(j=0;j<3;j++)
{for(i=0;i<3;i++)
printf("%4d",a[j][i]);
printf("\n");
}
system("pause");
return 0;
}
因为我的电脑输出程序的时候出现闪退现象,
加
//
#include<stdlib.h>
system("pause");//暂停的命令system("pause")
return 0;