c'est programme calcule inverse de matrice 3x3
***********Code cource***********
#include <iostream> using namespace std; //# include <conio.h> //# include<iostream.h> const int size = 9; int main() { char ch; do { //clrscr(); int i, j, x, y, z, det; int a[size], b[size]; cout << " **** Calculons l'inverse d'un matrice carreé n=3 ****" << endl << endl << endl; for (i = 0; i <= size; i++) /// saisir les element de matrice a[i]=0; for (i = 0; i < size; i++) { cout << "Entrer " << i + 1 << " element de matrice="; cin >> a[i]; cout << endl <<endl; } //clrscr(); cout << " Le matrice est : " /// L'affichage de matrice << endl <<endl; for (i = 0; i < size; i += 3) cout << a[i] << " " << a[i+1] << " " << a[i+2] << endl <<endl; cout << "Transpose de matrice est :" << endl << endl; for (i = 0; i < 3; i++) cout << a[i] << " " << a[i+3] << " " << a[i+6] << endl << endl; cout << "Determinent de matrice est: = "; /// calcul déterminant x = a[0] * (a[4] * a[8] -a [5] * a[7]); y = a[1] * (a[3] * a[8] -a [5] * a[6]); z = a[2] * (a[3] * a[7] -a [4] * a[6]); det = x - y + z; cout << det << endl << endl << endl << endl; if (det == 0) { cout << "Si Determinent=0 alors la matrice donee n'est pas inversible" << endl << endl; goto quit; } b[0] = a[4] * a[8] - a[5] * a[7]; b[1] = a[5] * a[6] - a[3] * a[8]; b[2] = a[3] * a[7] - a[4] * a[6]; b[3] = a[2] * a[7] - a[1] * a[8]; b[4] = a[0] * a[8] - a[2] * a[6]; b[5] = a[1] * a[6] - a[0] * a[7]; b[6] = a[1] * a[5] - a[2] * a[4]; b[7] = a[2] * a[3] - a[0] * a[5]; b[8] = a[0] * a[4] - a[1] * a[3]; cout << "Adjoint de matrice est :" /// l'affichage de comatrice << endl << endl; for (i = 0; i < 3; i++) { cout << b[i] << " " << b[i+3] << " " << b[i+6] << endl <<endl; } cout << endl <<endl; cout << "Inverse de matrice donne est : " /// afficher le résultat << endl << endl << endl; for (i = 0; i < 3; i++) { cout << b[i] << "/" << det << " " << b[i+3] << "/" << det << " " << b[i+6] << "/" << det << endl <<endl; } quit: cout << endl << endl; cout << "Si continue entrer (y/yes,n/no)"; /// pour répeter le testse sur auter matrice (y/n) cin >> ch; cout << endl << endl; } /* end do */ while (ch == 'y'); //getch (); return 0; }