#include<stdio.h>
#define Col 3
#define Row 2
void Input(int a[][Col]);
void Zhuanz(int b[][Row],int a[][Col]);
void Output(int a[][Col],int b[][Row]);
int main()
{
int a[Row][Col],b[Col][Row];
Input(a);
Zhuanz(b,a);
Output(a,b);
return 0;
}
void Input(int a[][Col]){
int i,j;
for(i=0;i<Row;i++){
for(j=0;j<Col;j++)
scanf("%d",&a[i][j]);
}putchar('\n');
}
void Zhuanz(int b[][Row],int a[][Col]){
int i,j;
for(i=0;i<Row;i++){
for(j=0;j<Col;j++){
b[j][i]=a[i][j];
}
}
}
void Output(int a[][Col],int b[][Row]){
int i,j;
for(i=0;i<Row;i++){
for(j=0;j<Col;j++){
printf("%6d",a[i][j]);
}putchar('\n');
}
printf("|");
for(i=0;i<Col;i++){
for(j=0;j<Row;j++){
printf("%6d",b[i][j]);
}putchar('\n');
}
}
实现矩阵的倒置
最新推荐文章于 2023-01-04 17:02:51 发布