Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- void main() {
- int n, i, j, s;
- double sum;
- double x[5];
- n = 2;
- double a[3][3] = {
- { 4, 1, 3 },
- { 0, 3.75, 0.25 },
- { 0, 0, 0.33 }
- };
- double b[3] = { 2, 0.5, 2.67 };
- x[n] = b[n] / a[n][n];
- std::cout << x[n] << std::endl;
- for (i = n - 1; i <= 0; i--) {
- sum = 0;
- for (s = i + 1; i <= n; i++) {
- sum = sum + a[i][s] * x[s];
- }
- x[i] = (b[i] - sum) / a[i][i];
- }
- for (i = 0; i <= n; i++){
- std::cout << x[i] << std::endl;
- }
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement