-7
我知道這似乎是一個老問題,但沒有人回答我搜索工作的問題。 我一直在收到「運行時檢查失敗#2 - 堆棧變量'b'被損壞。」當我試圖做[4] [2] * [2] [3]矩陣乘法。#EMERGENCY !!!運行時檢查失敗#2 - 圍繞變量'b'堆棧已損壞
有沒有人發現問題?
#include <stdio.h>
int main() {
int a[4][2] = {0};
int b[2][3] = {0};
int c[3][3] = {0};
int i, j;
printf("Please enter first matrix value\n");
for (i = 0; i < 4; i++) {
for (j = 0; j < 2; j++) {
printf("%d row, %d column:", i + 1, j + 1);
scanf("%d", &a[i][j]);
}
}
printf("Please enter second matrix value\n");
for (i = 0; i < 2; i++) {
for (j = 0; j < 3; j++) {
printf("%d row, %d column:", i + 1, j + 1);
scanf("%d", &b[i][j]);
}
}
printf("\n the result is :\n");//
for (i = 0; i < 4; i++) {
printf("[");
for (j = 0; j < 3; j++) {
c[i][j] = (a[i][0] * b[0][j]) + (a[i][1] * b[1][j]);
printf(" %4d ", c[i][j]);
}
printf("]\n");
}
return 0;
}
##不要提! – pm100
應該是'int c [4] [3] = {0}' – ptb