我是新手。我正在尝试添加两个矩阵。
虽然代码对我来说似乎很简单,但结果令人困惑。
到底是怎么回事?
程序代码:
#include <stdio.h>
int main()
{
int r, c, i, j;
printf("This program will add two matrices.\n");
//Determine the dimensions of the matrices
//(Matrix Addition stipulates that matrices have the same dimensions
// in order to be added.)
printf("What dimensions are the matrices?\n");
printf("Rows: ");
scanf("%d", &r);
printf("Columns: ");
scanf("%d", &c);
int matrixA[r][c], matrixB[r][c], matrixC[r][c];
//take elements of Matrix A and print them as a matrix.
printf("Enter the elements of the first matrix by row:\n");
for(i=0; i<r; …Run Code Online (Sandbox Code Playgroud)