#include<stdio.h>
int main(){
int a[2][3]{1,2,3,4,5,6};
int b[3][2];
for (int i=0;i<2;i++){
for (int j=0;j<3;j++){
b[j][i]=a[i][j];
}
}
for (int i=0;i<3;i++)
{
for (int j=0;j<2;j++){
printf("%d ",b[i][j]);
}
printf("\n");
}
#include<stdio.h>
int main() {
int arr1[2][3] = { 1,2,3,4,5,6 };
int arr2[3][2];
int i, j;
for (i = 0; i < 2; i++)
for (j = 0; j < 3; j++) {
arr2[j][i] = arr1[i][j];
}
for (i = 0; i < 3; i++) {
for (j = 0; j < 2; j++)
printf("%d", arr2[i][j]);
printf("\n");
}
return 0;
int main() {
int arr[2][3];
int k = 0;
int arr1[3][2];
int index = 1;
int m = 0, n = 0, i = 0, j = 0;
for ( i = 0; i < 2; i++) {
for (j = 0; j < 3; j++) {
arr[i][j] = index++;
}
}
for (i = 0; i < 2 ; i++) {
k = i;
for ( j = 0; j < 3; j++) {
arr1[j][k] = arr[i][j];
}
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 2; j++)
printf("%d ", arr1[i][j]);
}
return 0;
}
int main() {
int arr[2][3];
int k = 0;
int arr1[3][2];
int index = 1;
int m = 0, n = 0, i = 0, j = 0;
for ( i = 0; i < 2; i++) {
for (j = 0; j < 3; j++) {
arr[i][j] = index++;
}
}
for (i = 0; i < 2 ; i++) {
k = i;
for ( j = 0; j < 3; j++) {
arr1[j][k] = arr[i][j];
}
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 2; j++)
printf("%d ", arr1[i][j]);
}
return 0;
}
#include<stdio.h>
int main(){
int n[2][3]={{1,2,3},{4,5,6}};
int m[3][2];
int i,j,k=0;
for(i=0;i<2;i++){
for(j=0;j<3;j++){
m[j][k]=n[i][j];
}
k=1;
}
for(i=0;i<3;i++){
for(j=0;j<2;j++)
printf("%d\t",m[i][j]);
printf("\n");
}
登录后提交答案