C语言编程,下图怎么编程啊?

2024-11-25 05:25:24
推荐回答(2个)
回答1:

#include

int a[100][100]={1};

int main(){

int n=5,m=1;

    printf("原矩阵:\n");

for(int i=0;i

for(int j=0;j

a[i][j]=m++;

printf("%d",a[i][j]);

if(j

else printf("\n");

}

}

printf("转置矩阵:\n");

for(int i=0;i

for(int j=i;j

int tmp=a[i][j];

a[i][j]=a[j][i];

a[j][i]=tmp;

}

for(int i=0;i

for(int j=0;j

printf("%d",a[i][j]);

if(j

else printf("\n");

}

}

return 0;

}

回答2:

#include

#define N 5

#define M 4

void main() { int a[N][M],b[M][N],i,j,k;

for ( i=0,k=1;i

for ( i=0;i

for ( i=0;i

for ( i=0;i

}