C语言 题 请牛人解 急!!!!

来源:百度知道 编辑:UC知道 时间:2024/07/04 02:21:53
编写程序, 实现矩阵(3行3列)的转置(即行列互换)
例如, 输入下面的矩阵:
100 200 300
400 500 600
700 800 900
程序输出:
100 400 700
200 500 800
300 600 900
注意:请勿改动主函数main和其它函数中的任何内容, 仅在函数fun的花括号中填入你编写的若干语句。

#include
#include
int fun(int array[3][3])
{
int i,j,t;
for(i=0; i < 3; i++)
for(j=0; j < i; j++)
{

}
}
main()
{
int i,j;
int array[3][3]={{100,200,300},{400,500,600},{700,800,900}};
clrscr() ;
for (i=0; i < 3; i++)
{ for (j=0; j < 3; j++)
printf("%7d",array[i][j]);
printf("\n");
}
fun(array);
printf("Converted array:\n");
for (i=0; i < 3; i++)
{ for (j=0; j < 3; j++)
printf("%7d",array[i][j]);
printf("\n");
}
}

#include
#include
int fun(int array[3][3])
{
int i,j,t;
for(i=0; i < 3; i++)
for(j=0; j < i; j++)
{ t=array[i][j]
array[i][j]=array[j][i]
array[j][i]=t
}
}
main()
{
int i,j;
int array[3][3]={{100,200,300},{400,500,600},{700,800,900}};
clrscr() ;
for (i=0; i < 3; i++)
{ for (j=0; j < 3; j++)
printf("%7d",array[i][j]);
printf("\n");
}
fun(array);
printf("Converted array:\n");
for (i=0; i < 3; i++)
{ for (j=0; j < 3; j++)
printf("%7d",array[i][j]);
printf("\n");
}
}

#include"stdio.h"
#include <conio.h>

int fun(int array[3][3])
{
int i,j,t;
for(i=0; i < 3; i++)
for(j=0; j < i; j++)
{
t=array[i][j];
array[i][j]=array[j][i];
array[j][i]=t;

}