小编Pol*_*gon的帖子

C 语言的简单程序:添加两个矩阵。结果是怎么回事?

我是新手。我正在尝试添加两个矩阵。
虽然代码对我来说似乎很简单,但结果令人困惑。
到底是怎么回事?

程序代码:

#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)

c matrix

1
推荐指数
1
解决办法
96
查看次数

标签 统计

c ×1

matrix ×1