C语言矩阵相乘帮忙写一个程序要求:利用动态分配数组方式输入并存储A、B两矩阵,并求出两矩阵相乘结果.
来源:学生作业帮助网 编辑:六六作业网 时间:2025/02/02 05:08:13
C语言矩阵相乘帮忙写一个程序要求:利用动态分配数组方式输入并存储A、B两矩阵,并求出两矩阵相乘结果.
C语言矩阵相乘
帮忙写一个程序
要求:利用动态分配数组方式输入并存储A、B两矩阵,并求出两矩阵相乘结果.
C语言矩阵相乘帮忙写一个程序要求:利用动态分配数组方式输入并存储A、B两矩阵,并求出两矩阵相乘结果.
/* Matrix_main.cpp */
//
#include
#include
#include
#include
/* #include */
void main(void)
{
int col, row, row_s; /* the column & row of the matrix */
int **pM_f = NULL, **pM_s = NULL; /* point to two matrix,they will be multiplied */
int **pM_r = NULL; /* the matrix will store the result */
int i, j, k;
printf("Input column & row of the first matrix:\n(depart with blank): ");
scanf("%d %d", &col, &row);
printf("Input row of the second one:\n(column needn't): ");
scanf("%d", &row_s);
/* ---------------Request storage for process--------------- */
pM_f = (int**)malloc(col * sizeof(int*));
pM_s = (int**)malloc(row * sizeof(int*));
pM_r = (int**)malloc(col * sizeof(int*));
for (i=0; i