先表示delta再求解
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
double a, b, c, delta;
int main()
{
cin >> a >> b >> c;
delta = b * b - 4 * a * c;
if (delta < 0 || a == 0) cout << "Impossivel calcular" << endl;
else {
printf("R1 = %.5lf\nR2 = %.5lf", ((-1) * b + sqrt(delta)) / (2 * a),((-1) * b - sqrt(delta)) / (2 * a));
}
return 0;
}