using namespace std;
The class Matrix {
Private:
Int N;
Int * * matrix;
Public:
Matrix ();
~ Matrix ();
Matrix (int);
Void init ();
Void unit ();
Void the display ();
Matrix& The operator + (Matrix&);
Matrix& The operator * (Matrix & amp;);
Matrix& The Mul (Matrix& , int);//matrix and power
};
Matrix: : Matrix () {N=0; }
Matrix: : ~ Matrix () {
int i;
for(i=0; i
The delete [] matrix;
}
Matrix: : Matrix (int n) (n=n;
Matrix=new int * [N].
int i;
for(i=0; i
Int j;
for(i=0; i
}
Void Matrix: : unit () {
int i,j;
for(i=0; i
Matrix [I] [j]=1;
}
Void Matrix: : init () {
Int the row, col.
For (row=0; Row
}
}
Matrix& Matrix: : operator * (Matrix & amp; X) {
Int the row, col.
Int sum;
Matrix m (N);
For (row=0; Row
sum=0;
for(i=0; i
M.m atrix [row] [col]=sum;
}
X=m;//error ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '
return x;
}
Matrix& Matrix: : the Mul (Matrix& X, int n) {
Int bri [1000].
int count=0;
While (n!=0) {
Bri (count)=n % 2;
N=n/2;
Count++;
}
Matrix m (N);
M.u nit ();
For (int I=count - 1; I> - 1; I -) {
M=m * m.
If (bri [I]==1)
M=m * x;
}
X=m;
return x;
}
Void Matrix: : display () {
int i,j;
for(i=0; i
}
Cout<& lt; Endl;
}
}
Matrix& Matrix: : operator + (Matrix& X) {
int i,j;
Matrix m (N);
for(i=0; i
X=m;
return x;
}
Int main () {
int n;
Cout<& lt;" Input matrix order "& lt;
Matrix N (N);
N.i nit ();
Cout<& lt;" The input power & lt; ""
Matrix K (n);
K=N.M ul (N, N);
Cout<& lt;" For the matrix of: "& lt;
return 0;
}