求一道C语言(关于数组)的编程题

2024-12-17 12:50:10
推荐回答(2个)
回答1:

首先字义二维数组A[M][N],

函数如下:

main()
{

int i,j,Temp;
/*定义并初始化二维数组*/
int A[M][N]={{.......},{......},....{......}};
/*转置*/
for(i=0;i for(j=0;j if(i!=j)
{
Temp=Array[i][j];
Array[i][j]=Array[j][i];
Array[j][i]=Temp;
}
}

回答2:

#include
#define N 4
void main()
{ int a[N][N]={{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}};
int m,i,j;

for(i=0; i {for(j=0; j { printf("%d ",a[j][i]);}
printf("\n");
}
}