文件名称:juzhenxiangcheng
介绍说明--下载内容均来自于网络,请自行研究使用
编写程序,可以实现m*n矩阵和n*p矩阵相乘。m,n,p均小于10,矩阵元素为整数。
分析:
首先我们可以根据题意写出函数头。可以定为void MatrixMutiply(int m,int n,int p,long lMatrix1[MAX][MAX],long lMatrix2[MAX][MAX],long lMatrixResult[MAX][MAX]),其中lMatrix1和lMatrix2分别是输入的m*n矩阵和n*p矩阵,lMatrixResult是输出的m*p矩阵。
因为m,n和p都是未知量,要进行处理的矩阵大小是变量。但我们可以定义比较大的二维数组,只使用其中的部分数组元素。
矩阵相乘的算法比较简单,输入一个m*n矩阵和一个n*p矩阵,结果必然是m*p矩阵,有m*p个元素,每个元素都需要计算,可以使用m*p嵌套循环进行计算。
根据矩阵乘法公式:
可以用循环直接套用上面的公式计算每个元素。嵌套循环内部进行累加前,一定要注意对累加变量进行清零。-Write a program, you can achieve the m* n matrix and n* p matrix multiplied. m, n, p are less than 10, the matrix elements are integers. Analysis: First of all, we can write the function header according to the meaning of the questions. As void MatrixMutiply (int m, int n, int p, long lMatrix1 [MAX] [MAX], long lMatrix2 [MAX] [MAX], long lMatrixResult [MAX] [MAX]) of which lMatrix1 and lMatrix2, are input m* N matrix and n* p matrix, lMatrixResult is the output of m* p matrix. M, n and p are unknown quantity, the size of the matrix to be processed is variable. However, we can define a large two-dimensional arrays, which use only part of the array elements. M* p nested relatively simple matrix multiplication algorithm, the input of an m* n matrix, and an n* p matrix, the inevitable result is a matrix of m* p, there are m* p elements, each element needs to be calculated and can be used loop calculation. Matrix multiplication formula: cycle directly apply the above formula to calculate ea
分析:
首先我们可以根据题意写出函数头。可以定为void MatrixMutiply(int m,int n,int p,long lMatrix1[MAX][MAX],long lMatrix2[MAX][MAX],long lMatrixResult[MAX][MAX]),其中lMatrix1和lMatrix2分别是输入的m*n矩阵和n*p矩阵,lMatrixResult是输出的m*p矩阵。
因为m,n和p都是未知量,要进行处理的矩阵大小是变量。但我们可以定义比较大的二维数组,只使用其中的部分数组元素。
矩阵相乘的算法比较简单,输入一个m*n矩阵和一个n*p矩阵,结果必然是m*p矩阵,有m*p个元素,每个元素都需要计算,可以使用m*p嵌套循环进行计算。
根据矩阵乘法公式:
可以用循环直接套用上面的公式计算每个元素。嵌套循环内部进行累加前,一定要注意对累加变量进行清零。-Write a program, you can achieve the m* n matrix and n* p matrix multiplied. m, n, p are less than 10, the matrix elements are integers. Analysis: First of all, we can write the function header according to the meaning of the questions. As void MatrixMutiply (int m, int n, int p, long lMatrix1 [MAX] [MAX], long lMatrix2 [MAX] [MAX], long lMatrixResult [MAX] [MAX]) of which lMatrix1 and lMatrix2, are input m* N matrix and n* p matrix, lMatrixResult is the output of m* p matrix. M, n and p are unknown quantity, the size of the matrix to be processed is variable. However, we can define a large two-dimensional arrays, which use only part of the array elements. M* p nested relatively simple matrix multiplication algorithm, the input of an m* n matrix, and an n* p matrix, the inevitable result is a matrix of m* p, there are m* p elements, each element needs to be calculated and can be used loop calculation. Matrix multiplication formula: cycle directly apply the above formula to calculate ea
(系统自动生成,下载前可以参看下载内容)
下载文件列表
矩阵相乘.docx