2020-04-08 02:31:29 +03:00
|
|
|
#include <math.h>
|
2020-05-29 23:23:24 +03:00
|
|
|
#include <stdio.h>
|
2020-04-08 02:31:29 +03:00
|
|
|
|
|
|
|
int main()
|
2016-10-16 18:58:14 +03:00
|
|
|
{
|
2020-05-29 23:23:24 +03:00
|
|
|
float a, b, c, a1, a2, a3, b1, b2, b3, c1, c2, c3, d1, d2, d3, x1, x2, x3;
|
2020-04-08 02:31:29 +03:00
|
|
|
|
2020-05-29 23:23:24 +03:00
|
|
|
printf("Enter values of eq1:");
|
|
|
|
scanf("%f%f%f%f", &a1, &a2, &a3, &d1);
|
|
|
|
printf("Enter values of eq2:");
|
|
|
|
scanf("%f%f%f%f", &b1, &b2, &b3, &d2);
|
|
|
|
printf("Enter values of eq3:");
|
|
|
|
scanf("%f%f%f%f", &c1, &c2, &c3, &d3);
|
|
|
|
x1 = x2 = x3 = 0.0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
a = x1;
|
|
|
|
b = x2;
|
|
|
|
c = x3;
|
|
|
|
x1 = (1 / a1) * (d1 - (a2 * x2) - (a3 * x3));
|
|
|
|
x2 = (1 / b2) * (d2 - (b1 * x1) - (b3 * x3));
|
|
|
|
x3 = (1 / c3) * (d3 - (c1 * x1) - (c2 * x2));
|
|
|
|
} while (fabs(x1 - a) > 0.0001 && fabs(x2 - b) > 0.0001 &&
|
|
|
|
fabs(x3 - c) > 0.0001);
|
|
|
|
printf("x1=%f\nx2=%f\nx3=%f", x1, x2, x3);
|
2020-04-08 02:31:29 +03:00
|
|
|
|
2020-05-29 23:23:24 +03:00
|
|
|
return 0;
|
2016-10-16 18:58:14 +03:00
|
|
|
}
|