标签:结果 oid str 17. cout i++ using div class
#include<iostream> #include<string> #include<stdlib.h> using namespace std; void MatrixMul(double A[],double B[],int m,int n,int k,double C[]) { int i,j,l,u; for(i=0;i<m;i++) { for(j=0;j<k;j++) { u=i*k+j; C[u]=0.0; for(l=0;l<n;l++) { C[u] +=A[i*n+l]*B[l*k+j]; } } } } int main() { double A[3][3]={{1.0,2.0,3.0}, {4.0,5.0,6.0}, {7.0,8.0,9.0}}; double B[3][3]={{2.0,-2.0,1.0}, {1.0,3.0,9.0}, {17.0,-3.0,7.0}}; double C[3][3]; int m,n,k,i,j; m=3; n=3; k=3; cout<<"矩阵A B相乘的结果是:"<<endl; MatrixMul(*A,*B,m,n,k,*C); for(i=0;i<m;i++) { for(j=0;j<n;j++) { cout<<C[i][j]<<endl; } } return 0; }
标签:结果 oid str 17. cout i++ using div class
原文地址:https://www.cnblogs.com/chuxinbubian/p/10528526.html