#include <math.h>
#include <stdio.h>
int main(void)
{
float a, b, c; //input
float x1, x2; //output
float D;
float eps = 1e-6;
printf("Введите 3 числа через enter\n");
scanf("%f %f %f", &a, &b, &c);
if (fabsf(a) < eps)
{
printf("The data isn't correct!");
}
else {
D = b * b - 4 * a * c;
if (D < 0)
{
printf("The solution isn't correct!");
}
else {
if (fabsf(D) < eps) //|D-6| < eps
{
x1 = -b / (2 * a);
printf("x1: %f", x1);
}
else {
x1 = (-b + sqrt(D)) / (2 * a);
x2 = (-b - sqrt(D)) / (2 * a);
//printf("(x1, x2): (%f, %f)", x1, x2);
printf("x1 = %f\n", x1);
printf("x2 = %f", x2);
}
}
}
printf("\n\n\n");
/*
Вывод
gcc -lm test.c && ./a.out
Введите 3 числа через enter
1
2
3
The solution isn't correct!
*/
return(0);
}