codeup之矩阵转置
生活随笔
收集整理的這篇文章主要介紹了
codeup之矩阵转置
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Description
將一個2行3列的矩陣(二維數組)行列互換,存儲到另一個3行2列的矩陣中。
要求以整型數據為例來解答。
Input
輸入2行數據,每行3個整數,以空格分隔。
Output
行列互換后的矩陣,3行,每行2個數據,以空格分隔。
Sample Input Copy
1 2 3
4 5 6
Sample Output Copy
1 4
2 5
3 6
solution
#include <stdio.h>
int main(){
int a[3][2];
for(int i = 0; i < 2; i++)
for(int j = 0; j < 3; j++)
scanf("%d", &a[j][i]);
for(int i = 0; i < 3; i++){
for(int j = 0; j < 2; j++)
printf("%d ", a[i][j]);
printf("\n");
}
return 0;
}
總結
以上是生活随笔為你收集整理的codeup之矩阵转置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: codeup之C语言10.10
- 下一篇: 【HUST】网安|操作系统实验|实验二