#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int main()
{
double a, b, c;
cin >> a >> b >> c;
if (b * b - (4 * c * a) < 0 || a == 0) cout << "Impossivel calcular" << endl;
if (b * b - (4 * a * c) > 0 && a != 0)
printf("R1 = %.5lf\nR2 = %.5lf", (-b + sqrt(b * b - 4 * a * c )) / (2 * a), (-b - sqrt(b * b - 4 * a * c))/ (2 * a));
return 0 ;
}
唯一一点就是注意a的问题:
a == 0和判别式 < 0时都为无解情况
有解时要注意有两个情况!!!