C++代码
#include<bits/stdc++.h>
using namespace std;
int main(){
double a,b,c;
cin>>a>>b>>c;
if(b*b<4*a*c||a==0.0){
printf("Impossivel calcular\n");
}else{
printf("R1 = %.5lf\n",(-b+sqrt(b*b-4*a*c))/(2*a));
printf("R2 = %.5lf\n",(-b-sqrt(b*b-4*a*c))/(2*a));
}
//1.在什么情况下判定方程无解 (b*b−4*a*c)<0
//2.R1=??? 第一种:+ (-b+sqrt(b*b-4*a*c))/(2*a)
//3.R2=??? 第二种:- (-b-sqrt(b*b-4*a*c))/(2*a)
return 0;
}