Написание программы, демонстрирующей работу с классом, страница 3

}

double TMatr::Minor(int x,int y){

                  TMatr q(c-1,r-1);

                  int p=0,t=0;

                  for (int i=0;i<r;i++){

                                    for (int j=0;j<c;j++){

                                                     if (i!=x && j!=y){

                                                                       q.a[p][t]=a[i][j];

                                                                       t++;

                                                     }

                                    }

                                    if (t==q.r){

                                                     p++;

                                                     t=0;

                                    }

                  }

                  return q.det(q.r);

}

void TMatr::ObratMatr(){

                  TMatr q(r,c);

                  int p=0;

                  double d=det(r);

                  for (int i=0;i<r;i++){

                                    for (int j=0;j<c;j++){

                                                     q.a[i][j]=a[i][j];

                                    }

                  }

                  for (int i=0;i<r;i++){

                                    for (int j=0;j<c;j++){

                                                     a[j][i]=q.Minor(i,j)/d*pow(-1.0,p);

                                                     p++;

                                    }

                  }

}

void TMatr::MatrType(){

                  if (TypeSq()==true){

                                    if (TypeDownRec()==true && TypeUpRec()==true &&

                                                     TypeOne()==true){

                                    cout<<"This is single matrix"<<endl;

                                    } else if (TypeDownRec()==true && TypeUpRec()==true &&

                                                     TypeZero()==true){

                                    cout<<"This is zero matrix"<<endl;

                                    } else if (TypeDownRec()==true && TypeUpRec()==true){

                                    cout<<"This is diagonal matrix"<<endl;

                                    }else if (TypeUpRec()==true){

                                    cout<<"Type of the matrix is upper rectangle"<<endl;

                                    } else if (TypeDownRec()==true){

                                    cout<<"Type of the matrix is down rectangle"<<endl;

                                    } else if (TypeSimetr()==true){

                                    cout<<"This is symmetrical matrix"<<endl;

                                    }else cout<<"This is square matrix"<<endl;

                  }else cout<<"This is matrix "<<r<<"x"<<c<<endl;

}

bool TMatr::TypeSq(){

                  bool res=true;

                  if (r!=c) res=false;

                  else return res;

}

bool TMatr::TypeUpRec(){

                  bool res=true;

                  for (int i=1;i<r;i++){

                                    for (int j=0;j<i;j++){

                                                     if (a[i][j]!=0){

                                                                       res=false;

                                                                       break;

                                                     }

                                    }

                  }

                  return res;

}

bool TMatr::TypeDownRec(){

                  bool res=true;

                  for (int i=0;i<r-1;i++){

                                    for (int j=i+1;j<r;j++){

                                                     if (a[i][j]!=0){

                                                                       res=false;

                                                                       break;

                                                     }

                                    }

                  }

                  return res;

}

bool TMatr::TypeZero(){

                  bool res=true;

                  for (int i=0;i<r;i++){

                                    if (a[i][i]!=0){

                                                     res=false;

                                                     break;

                                    }

                  }

                  return res;

}

bool TMatr::TypeOne(){

                  bool res=true;

                  for (int i=0;i<r;i++){

                                    if (a[i][i]!=1){

                                                     res=false;

                                                     break;

                                    }

                  }

                  return res;

}

bool TMatr::TypeSimetr(){

                  bool res=true;

                  for (int i=1;i<r-1;i++){

                                    if (a[i][0]!=a[0][i]){

                                                     res=false;

                                                     break;

                                    }

                  }

                  return res;

}

void TMatr::menu(){

                  string s;

                  cout<<"___________________________"<<endl;

                  cout<<"1: Addition of matrices"<<endl;//сложение

                  cout<<"2: Subtraction of matrices"<<endl;//вычитание

                  cout<<"3: Multiplication of matrices"<<endl;//умножение

                  cout<<"4: Division of matrices"<<endl;//деление