void ArrayMultiplication(int a[],int b[],int c[],int n,int m,int p){
for(int i=0;i
题目:
用一维数组表示矩阵,完成任意两个矩阵(10*10以内)a*b运算,结果放在c矩阵中;
函数接口定义:
在这里描述函数接口。例如: void ArrayMultiplication(int a[],int b[],int c[],int n,int m,int p);
矩阵A为n*m矩阵,B矩阵为m*p矩阵,C=A*B 故C为n*p矩阵
以下函数不用编写,测试程序已经完成。
void initArray(int x[],int n,int m);//初始化矩阵x为n行,m列;
//将一维数组x表示的矩阵以n行m列的形式输出;
void PrintArray(int x[],int n,int m)
裁判测试程序样例:
在这里给出函数被调用进行测试的例子。例如: #include #define M 10 #define N 10 //矩阵A为n*m矩阵,B矩阵为m*p矩阵,C=A*B 故C为n*p矩阵 void ArrayMultiplication(int a[],int b[],int c[],int n,int m,int p); int main() { int a[M*N],b[M*N],c[M*N]; int n,m,p; scanf("%d%d%d",&n,&m,&p); initArray(a, n, m); initArray(b, m, p); printf("矩阵a为n"); PrintArray(a, n, m); printf("矩阵b为n"); PrintArray(b, m, p); ArrayMultiplication(a,b,c,n,m,p); printf("矩阵a*b 为n"); PrintArray(c, n, p); return 0; }
输入样例:
在这里给出一组输入。例如:
2 3 4
输出样例:
在这里给出相应的输出。例如:
矩阵a为
1 2 3
4 5 6
矩阵b为
1 2 3 4
5 6 7 8
9 10 11 12
矩阵a*b 为
38 44 50 56
83 98 113 128 


