變長數組_相乘取結果
阿新 • • 發佈:2017-06-17
tdi class pri -a mod main 輸出 array objc
//變長數組 相乘取結果 #include <stdio.h> int main(void){ // int array_01[3][4] = {1,2,3,4,5,6,7,8,9,10,11,12}; int array_02[4][3] = {12,11,10,9,8,7,6,5,4,3,2,1}; int result[3][3] = {0}; int i, j, k; for (i = 0; i < 3; i ++){ //遍歷array_01數組元素 for (j = 0;j < 3; j ++){ // 遍歷array_02數組元素 for (k = 0; k < 4; k++ ){ //賦給第三個數組 c[i][j] += a[i][k] * b[k][j]; //返回結果 } } } //打印輸出 for (i = 0; i < 3; i ++){ for (j = 0; j < 3; j ++){ printf("%4d",c[i][j]); } printf("\n"); } return 0; }
變長數組_相乘取結果