Ответы
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
double a, b, c, z, v, w;
std::cin >> a >> b >> c;
z = a / b;
v = (1.0/3.0) * a * b;
w = c * c * c;
a = z;
b = v;
c = w;
double D = b * b - 4.0 * a * c;
if( a == 0.0)
{
double x = -c / b;
std::cout << "X = " << x << std::endl;
}
else if (b == 0.0 && -c / a > 0.0)
{
double x1 = std::sqrt(-c / a);
double x2 = -std::sqrt(-c / a);
std::cout <<"X1 = " << x1 << ", X2 = " << x2 << std::endl;
}
else if (D == 0.0)
{
double x = -b / (2.0 * a);
std::cout <<"X = " << x << std::endl;
}
else if (D > 0.0)
{
double x1 = (-b - std::sqrt(D)) / (2.0 * a);
double x2 = (-b + std::sqrt(D)) / (2.0 * a);
std::cout <<"X1 = " << x1 << ", X2 = " << x2 << std::endl;
}
else
{
std::cout << "D < 0, корней нет" << std::endl;;
}
return 0;
}