//变长数组 相乘取结果 #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; }
时间: 2024-10-10 13:22:53