Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Matrice.h"
- #include <time.h>
- #include <iostream>
- using namespace std;
- Matrice::Matrice(int _NbLignes, int _NbColonnes)
- {
- int i;
- int j;
- srand (time(NULL));
- NbLignes = _NbLignes;
- NbColonnes = _NbColonnes;
- Tableau = new int*[NbLignes];
- if(!(Tableau == NULL))
- {
- for(i = 0; i < NbLignes; i++)
- {
- Tableau[i] = new int[NbColonnes];
- if(!(Tableau[i] == NULL))
- {
- for(j = 0; j < NbColonnes; j++)
- {
- Tableau[i][j] = rand() % 100 + 1;
- }
- }
- }
- }
- }
- Matrice::Matrice(void)
- {
- }
- Matrice::~Matrice(void)
- {
- int i;
- int j;
- for(i = 0; i < NbLignes; i++)
- {
- delete[] Tableau[i];
- }
- delete[] Tableau;
- }
- bool Matrice::Null()
- {
- for(int i = 0; i < NbLignes; i++)
- {
- for(int j = 0; j < NbColonnes; j++)
- {
- if (Tableau[i][j]!=0) return false;
- }
- }
- return true;
- }
- void Matrice::Afficher()
- {
- for(int i = 0; i < NbLignes; i++)
- {
- for(int j = 0; j < NbColonnes; j++)
- {
- printf("%d\t",Tableau[i][j]);
- }
- printf("\n");
- }
- }
- bool Matrice::TriangulaireSup()
- {
- return BasNull();
- }
- bool Matrice::TriangulaireSrict()
- {
- return (!Null && DiagoNul() && BasNull());
- }
- bool Matrice::DiagoNul()
- {
- for (int i = 0; i<NbLignes; i++)
- {
- if (Tableau [i][i] != 0) return false;
- }
- return true;
- }
- bool Matrice::Scalaire()
- {
- int nb = Tableau[0][0];
- for (int i = 0; i<NbLignes; i++)
- {
- if (Tableau [i][i] != nb && HautNull() && BasNull()) return false;
- }
- return true;
- }
- bool Matrice::BasNull()
- {
- int k = 1 ;
- for (int j = 0; j<NbColonnes; j++)
- {
- for (int i = k; i<NbLignes; i++)
- {
- if (Tableau [i][j] != 0) return false;
- }
- k++;
- }
- }
- bool Matrice::HautNull()
- {
- int k = 0 ;
- for (int j = 1; j<NbColonnes; j++)
- {
- for (int i = 0; i<k+1; i++)
- {
- if (Tableau [i][j] != 0) return false;
- }
- k++;
- }
- }
- bool Matrice::Diagonale()
- {
- return (!DiagoNul() && HautNull() && BasNull());
- }
- bool Matrice::Unite()
- {
- for (int i = 0; i<NbLignes; i++)
- {
- if (Tableau [i][i] != 1) return false;
- }
- return true;
- }
- bool Matrice::Symetrique()
- {
- int i = 1;
- int j = 0;
- do
- {
- for(i; i < NbLignes; i++)
- {
- if(Tableau[i][j] != Tableau[j][i])return false;
- }
- j++;
- i = j;
- }
- while(j < NbLignes);
- return true;
- }
Add Comment
Please, Sign In to add comment