Task Description
輸入一個3 X 3矩陣,再將矩陣進行轉置,轉置規則如下圖


Hint
conver.h
打上 function header 以及相關的設定。
1 | void convert(int a[3][3], int b[3][3]);
|
conver.c
撰寫程式碼後對應上傳。
1 2 3 | void convert(int a[3][3], int b[3][3]){
}
|
main.c
這個檔案無法更改也無須上傳。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include <stdio.h>
#include <stdlib.h>
#include "convert.h"
int main(){
int a[3][3], b[3][3], i, j;
for(i = 0; i < 3; i++) {
for(j = 0; j < 3; j++) {
scanf("%d", &a[i][j]);
}
}
convert(a, b);
for(i = 0; i < 3; i++) {
for(j = 0; j < 3; j++) {
printf("%d ", b[i][j]);
}
printf("\n");
}
return 0;
}
|
Input Format
輸入一個3 X 3矩陣
Output Format
輸出3 X 3轉置矩陣,矩陣每行最後面多一個空格
Sample Input
Sample Output