作业帮 > 综合 > 作业

C语言矩阵相乘帮忙写一个程序要求:利用动态分配数组方式输入并存储A、B两矩阵,并求出两矩阵相乘结果.

来源:学生作业帮 编辑:搜搜做题作业网作业帮 分类:综合作业 时间:2024/04/29 19:19:29
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