Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. #include<iostream>
  2. #include<stdio.h>
  3. #include<math.h>
  4. #include<stdlib.h>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9.     //maatrice A
  10.     double matrice [3][3]={{1,1,-1},{1,-2,3},{2,3,1}};
  11.     int m=3;
  12.     int n=3;
  13.     //matrice b
  14.     double matrice2 [3][1]= {{4.6923},{-0.7692},{-0.0769}};
  15.     int p=3;
  16.     int q=1;
  17.     double somme=0;
  18.     //matrice final
  19.     double matrice3[3][3];
  20.  
  21.     int c, d, k;
  22.     if(n !=p) {
  23.         cout << "matrice incompatible" << endl;
  24.     } else {
  25.         for(c=0;c<m;c++) {
  26.             for(d=0;d<q;d++) {
  27.                 for(k=0;k<p;k++)  {
  28.                     somme=somme+matrice[c][k]*matrice2[k][d];
  29.                 }
  30.                 matrice3[c][d]=somme;
  31.                 somme=0;
  32.             }
  33.         }
  34.     }
  35.        
  36.     for(c=0;c<m;c++) {
  37.         for (d=0;d<q;d++) {
  38.             cout <<  matrice3[c][d] << "\t" << endl;
  39.         }
  40.     }
  41.    
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement