Home > Back-end >  And a big look at why this matrix determinant calculation can not run normally
And a big look at why this matrix determinant calculation can not run normally

Time:11-06

#include
#include
The class deter
{
Int the order;
Double * * _deter;
Public:
Deter (int);
To deter () {delete [] _deter; }
Deter (deter&);
Void GetDeter ();
Void the Display ();
Friend void Calculate (deter);
};
Deter: : deter (int n) : the order (n)
{
_deter=new double * [order].
for(int i=0; i_deter [I]=new double [order].
}
Deter: : deter (deter & amp; X)
{
The order=x.o. rder;
_deter=new double * [x.o. rder];
for(int i=0; i_deter [I]=new double [x.o. rder];
for(int i=0; i{
for(int j=0; j{
_deter [I] [j]=x. _deter [I] [j];
}
}
}
Void deter: : GetDeter ()
{
Cout<& lt;" Please enter the determinant "& lt; for(int i=0; i{
for(int j=0; j{
Cin> _deter [I] [j];
}
}
}
Void deter: : Display ()
{
for(int i=0; i{
for(int j=0; j{
Cout}
Cout}
}
Void Calculate (deter x)
{
Double d;
Double the result=1;
For (int p=1; p{
If (x. _deter [p] [1] p==0)
continue;
The else
{
For (int m=p; m{
D=- x. _deter [m] [1] p/x. _deter [p - 1] [1] p;
for(int n=0; N{
X. _deter [m] [n] +=d * x. _deter [p - 1] [n].
}
}
}
}
for(int i=0; i{
The result *=x. _deter [I] [I];
}
Cout<& lt;" The determinant result to "& lt; }
Void main ()
{
int n;
Cout<& lt;" Please enter the determinant order "& lt; Cin> n;
Deter a (n);
Atul gawande etDeter ();
Cout<& lt;" Here is that you just input the determinant "& lt; A. d. isplay ();
Calculate (a);
}

CodePudding user response:

   please bosses under the kang
  • Related