#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define maxsize 3
#define transsize 3
void trans(int A[][maxsize],int B[][transsize],int m, int n){
printf("转置前----
");
for (int i = 0; i < m; ++i) {
for (int j = 0; j < n; ++j) {
printf("%d ",B[i][j]);
}
printf("
");
}
for (int i = 0; i < m; ++i) {
for (int j = 0; j < n; ++j) {
B[j][i] = A[i][j];
}
}
printf("转置后----
");
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
printf("%d ",B[i][j]);
}
printf("
");
}
}
int main(){
int a[][maxsize]={{1,2,3},{4,5,6},{7,8,9}};
int b[][transsize]={{1,2,3},{4,5,6},{7,8,9}};
trans(a,b,transsize,maxsize);
return 0;
}