Home > Back-end >  Strives for the benefactor to run it and see where is wrong?
Strives for the benefactor to run it and see where is wrong?

Time:09-16

/*
Implement the product of two dynamic matrix algorithm (linear algebra)
*/
/*
Errors may be in 55 to 70 rows, you can try running ~
*/


#include
using namespace std;
Int main ()
{
Int m1, n1, m2, n2;
Dm2 dm1 int * *, * * and * * dm3.
Cout & lt; <"Both Please input the first matrix size m1, n1:";
Cin & gt;> M1 & gt;> N1.

Dm1=new int * (m1);//matrix dm1, establishes the m1 line
for (int i=0; i If ((dm1 [I]=new int (n1))==NULL)
exit(0);
}
Cout & lt; <"Please input matrix dm1:";
for (int i=0; i For (int j=0; J & lt; N1. J++)
Cin & gt;> Dm1 [I] [j];
}


Cout & lt; <"Both Please input the first matrix size m2, n2:";
Cin & gt;> M2 & gt;> N2.
Dm2=new int * (m2), Line/dm2/matrix, the establishment of the m2
for (int i=0; i If ((dm2 [I]=new int [n2])==NULL)
exit(0);
}

Cout & lt; <"Please input matrix dm2:";
for (int i=0; i For (int j=0; J & lt; N2. J++)
Cin & gt;> Dm2 [I] [j];
}

If (n1! M2)={
Cout & lt; <"Input error matrix, please input again!!!!!! ";
}
The else {
//the new matrix ranks as m1, n2
Dm3=new int * (m1);//dm3 matrix, the establishment of the m1 line
for (int i=0; i If ((dm3 [I]=new int [n2])==NULL)
exit(0);
}
//input dm3
for (int i=0; i For (int j=0; J & lt; N2. J++) {
For (int x=0; X & lt; M2; X++) {
Dm3 [I] [j] +=dm1 dm2 [I] [x] * [x] [j];
}
}
}

for (int i=0; i {
For (int j=0; J & lt; N2. J++)
{
Cout & lt; }
Cout & lt; <"\ n";
}

}

//release space
for (int i=0; i The delete [] dm1 [I];
}
The delete [] dm1;


for (int i=0; i The delete [] dm2 [I];
}
The delete [] dm2;

system("pause");
return 0;





}
  • Related