给学弟学妹出的一道考核拓展题
#include<stdio.h>
#define row 4//行
#define col 4//列
typedef int Elementtype;
int i = 0, j = 0;
void Matrix_convert(Elementtype a[row][col])
{
Elementtype temp;
for (i = 0; i < row; i++)//行
{
for (j = 0; j < i; j++)//列
{
temp = *(*(a+i)+j);
*(*(a + i) + j)=*(*(a + j) + i);
*(*(a + j) + i) = temp;
}
}
}
void Input(Elementtype a[row][col])
{
for(i = 0; i < row; i++)
for (j = 0; j < col; j++)
scanf("%d",&a[i][j]);
}
void Output(Elementtype a[row][col])
{
for(i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
printf("%d\t",a[i][j]);
printf("\n");
}
}
int main()
{
Elementtype a[row][col];
Input(a);
Output(a);//打印转置前的矩阵
printf("\n");
Matrix_convert(a);
Output(a);//打印转置后的矩阵
}