小编Ton*_*ano的帖子

如何在C++中乘以两个10x10阵列?

我目前正在尝试编写一个程序,该程序使用一个函数,该函数将3个不同的10x10数组作为参数,并使用前2个数组的乘积填充第3个数组.

我已经在网上搜索,试图自己解决问题,但到目前为止,我只想出了这个:

(我用2个填充第一个数组,用3个填充第二个数组)

#include <iostream>

using std::cout;
using std::cin;
using std::endl;

/************************************************
** Function: populate_array1
** Description: populates the passed array with 2's
** Parameters: 10x10 array
** Pre-Conditions:
** Post-Conditions:
*************************************************/
void populate_array1(int array[10][10])
{
  int i, n;
  for (i = 0; i<10; i++)
  {
    for (n = 0; n<10; n++)
    {
      array[i][n] = 2;
    }
  }
}

/************************************************
** Function: populate_array2
** Description: populates the passed array with 3's
** Parameters: 10x10 array
** Pre-Conditions:
** Post-Conditions:
*************************************************/ …
Run Code Online (Sandbox Code Playgroud)

c++ arrays multidimensional-array matrix-multiplication

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