#include<stdio.h>
#include<math.h>
int main(){
void F(double a, double b, double c);
double a, b, c;
printf("请输入a b c:");
scanf_s("%lf %lf %lf", &a, &b, &c);
F(a, b, c);
return 0;
}
void F(double a, double b, double c) {
double resl, res2;
if (pow(b, 2) - 4 * a * c > 0) {
resl = (-b + sqrt(pow(b, 2) - 4 * a * c)) / (2 * a);
res2 = (-b - sqrt(pow(b, 2) - 4 * a * c)) / (2 * a);
printf("这个一元二次方程的根不同,分别为 %lf与 %lf\n", resl, res2);
}
if (pow(b, 2) - 4 * a * c == 0) {
resl = (-b + sqrt(pow(b, 2) - 4 * a * c)) / (2 * a);
printf("这个一元二次方程的两根相同,都为 %lf\n", resl);
}
if (pow(b, 2) - 4 * a * c < 0) {
printf("这个一元二次方程没有实数根,无解\n");
}
return;
}