1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
#include<iostream.h>
#include<conio.h>
#include<math.h>
class matrix
{
int a[10][10],n;
public:
matrix();
void seeMat();
void detmnt();
};
main()
{
matrix m;
m.seeMat();m.detmnt();
getch();
}
matrix::matrix()
{
int i,j;
cout<<"Enter order f matrix : ";cin>>n;
cout<<"Enter the elements \n";
for(i=0;i<n;i++)
for(j=0;j<n;j++)
cin>>a[i][j];
}
void matrix::seeMat()
{
int i,j;
cout<<"The Matrix is\n";
for(i=0;i<n;i++){
for(j=0;j<n;j++)
cout<<a[i][j]<<" ";cout<<"\n";}
}
void matrix::detmnt()
{
int det(int b[10][10],int m);
cout<<"det is "<<det(a,n);
}
int det(int b[10][10],int m)
{
int sum=0,x=0,y=0,i=0,j,aa,bb,c[10][10];
if(m==2)
return(b[0][0]*b[1][1]-b[0][1]*b[1][0]);
else
{
for(j=0;j<m;j++)
{
for(aa=0,y=0;aa<m;aa++)
{
for(bb=0;bb<m;bb++)
{
}
if(y>0)x++;
y=0;
}
sum=sum+b[i][j]*pow(-1,i+j)*det(c,m-1);
}
}
return sum;
}
|