Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(matrix[0][0] != 0){
- // Make the 1st element = 1
- for(int j=0; j<3; j++){
- matrix[0][j] = matrix[0][j] / matrix[0][0];
- }
- // Make element (2,1) = matrix[1][0] = 0
- /* for(int j=0; j<3; j++){
- matrix[1][j] = matrix[1][j] - (matrix[1][0] / matrix[0][0]) * matrix[0][j];
- }
- */
- int a = matrix[1][0] / matrix[0][0];
- matrix[1][0] -= a * matrix[0][0];
- matrix[1][1] -= a * matrix[0][1];
- matrix[1][2] -= a * matrix[0][2];
- // Make element (2,1) = matrix[1][0] = 0
- for(int j=0; j<3; j++){
- matrix[2][j] = matrix[2][j] - (matrix[2][0] / matrix[0][0]) * matrix[0][j];
- }
- }
- // 4. Show the 1st step
- show(matrix);
- cout << endl << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement