#include
int main()
{
int a[2][3]={{1,2,3},{4,5,6}};
int b[3][2],i,j;
for (i=0;i<=2;i++)
{
for (j=0;j<=1;j++)
{ b[i][j]=a[j][i];
printf("%5d",b[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 a[2][3]={1,2,3,4,5,6};
int b[3][2]={0};
int i,j;
for(i=0;i<2;i++){
for(j=0;j<3;j++){
b[j][i]=a[i][j];
}
}
for(i=0;i<3;i++){
for(j=0;j<2;j++){
printf("%d",b[i][j]);
}
printf("\n")
}
}
void Exchange(int A[][3], int B[][2], int row, int col) { //编写程序,将一个2×3的二维数组行、列互换,存入另一个3×2的二维数组中。(说明:2×3二维数组的数值可以初始化赋值,也可以通过键盘输入方式实现)
for (int i = 0; i < row; ++i)
for (int j = 0; j < col; ++j)
B[j][i] = A[i][j];
}
#include <stdio.h>
int main(){
int a[2][3]={{1,2,3},{4,5,6}};
int b[3][2],i,j;
for (i=0;i<=2;i++){
for (j=0;j<=1;j++){
b[i][j]=a[j][i];
printf("%d ",b[i][j]);
}
printf("\n");
}
return 0;
}
#include<stdio.h>
int main()
{
int i, j;
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];
#include<stdio.h>
int main()
{
int k = 0;
int a[2][3]={{1,2,3},{4,5,6}};
int b[3][2]={0};
for(int i = 0; i < 2; ++i)
{
for(int j = 0; j < 3; ++j)
{
b[j][i] = a[i][j];
//void reverse(int a[][3], int b[][2]) {
// int i, j;
// for (i = 0; i < 2; i++) {
// for (j = 0; j < 3; j++) {
// b[j][i] = a[i][j];
// }
// }
//}
int main() {
void reverse(int a[][3], int b[][2]);
int a[2][3];
int b[3][2];
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 3; j++) {
printf("please input a[%d][%d]\n", i, j);
int x = 0;
scanf("%d", &x);
a[i][j] = x;
}
}
printf("before reverse!\n");
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 3; j++) {
printf("a[%d][%d] is: %d\t", i, j, a[i][j]);
}
}
int i, j;
for (i = 0; i < 2; i++) {
for (j = 0; j < 3; j++) {
b[j][i] = a[i][j];
}
}
printf("\n");
printf("after reverse!\n");
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 2; j++) {
printf("b[%d][%d] is: %d\n", i, j, b[i][j]);
}
}
登录后提交答案