Advertisement
makispaiktis

Διαγωνοποίηση

Sep 17th, 2018 (edited)
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. if(matrix[0][0] != 0){
  2.  
  3.         // Make the 1st element = 1
  4.         for(int j=0; j<3; j++){
  5.  
  6.             matrix[0][j] = matrix[0][j] / matrix[0][0];
  7.         }
  8.  
  9.         // Make element (2,1) = matrix[1][0] = 0
  10.   /*      for(int j=0; j<3; j++){
  11.  
  12.             matrix[1][j] = matrix[1][j] - (matrix[1][0] / matrix[0][0]) * matrix[0][j];
  13.         }
  14. */
  15.         int a = matrix[1][0] / matrix[0][0];
  16.         matrix[1][0] -= a * matrix[0][0];
  17.         matrix[1][1] -= a * matrix[0][1];
  18.         matrix[1][2] -= a * matrix[0][2];
  19.  
  20.         // Make element (2,1) = matrix[1][0] = 0
  21.         for(int j=0; j<3; j++){
  22.  
  23.             matrix[2][j] = matrix[2][j] - (matrix[2][0] / matrix[0][0]) * matrix[0][j];
  24.         }
  25.  
  26.     }
  27.  
  28.     // 4. Show the 1st step
  29.     show(matrix);
  30.  
  31.     cout << endl << endl;
  32.  
  33.     return 0;
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement