用C语言实现矩阵转置

2020-10-28 教育 175阅读
//Transpose
#include
#define MAX 20
int m,n;
void transpose(double a[][MAX],double b[][MAX])
{
int i,j;
for(i=0;i for(j=0;j b[i][j]=a[j][i];
}
void main()
{
int i,j;
double a[MAX][MAX],b[MAX][MAX];
puts("Please input the dimensions of the matrixe:");
puts("(in term of “2 3”).");
scanf("%d %d",&m,&n);
puts("Enter the matrix:");
for(i=0;i for(j=0;j scanf("%lf",&a[i][j]);
transpose(a,b);

puts("The Transpose as follow:");
for(i=0;i {
for(j=0;j {
if(b[i][j]-int(b[i][j])!=0)
printf("%lf ",b[i][j]);
else
printf("%d ",int(b[i][j]));
}
puts("");
}
}
//我这个能实现任意大小的,还有提示输入输出
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com