This assignment aims to implement a C++ program that solves linear equations using the Gauss-Jordan elimination method.
-
Read Input:
- Read an integer
n
representing the number of variables from the first line. - Read
n
equations in the form of Ax + By + Cz + ... = k from the nextn
lines. (Actual format ism A B C D...
) wherem
represents the number of coefficients, A, B, C, D... are the coefficients separated by a space.
- Read an integer
-
Implementation:
- Implement an algorithm to solve the system of linear equations.
- Ensure your program handles cases where the system may not have a solution.
-
Output:
- If the system of equations is not solvable, output "NO."
- If the system is solvable, output "YES" and x, y, z, ... values with two decimal places.
Submit the C++ source code file in the GitHub repository, similar to how you submitted the previous assignment.
- Please make sure to implement your solution using the provided theory references.
- Ensure that your program handles edge cases where the system may not be solvable.
3
4 2 1 -1 8
4 -3 4 2 1
4 1 -1 3 6
3 2 3 -1
YES
2.00 -1.00 3.00
In the given example, the system of equations is solvable. The x, y, and z values are 2.00, -1.00, and 3.00, respectively. The output is formatted with two decimal places. If the system were not solvable, the output would be "NO."