#include #define SIZE 3 // 矩阵的大小 int main() { // 初始化矩阵 int matrix1[SIZE][SIZE] = { { 1, 2, 3 }, { 3, 4, 5 }, { 3, 4, 5 } }; int matrix2[SIZE][SIZE] = { { 4, 5, 6 }, { 6, 7, 8 }, { 6, 7, 8 } }; int result[SIZE][SIZE] = { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } }; int n = SIZE; int count = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { result[i][j] = 0; for (int k = 0; k < n; k++) { result[i][j] += matrix1[i][k] * matrix2[k][j]; count++; } } } // 输出结果 for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { printf("%d ", result[i][j]); } printf("\n"); } printf("N: %d, count: %d\n", n, count); return 0; }