//顺便排了一下版,这回OK了:)
#include<stdio.h>
#include<math.h>
int main(){
double a, b, c, x1, x2;
scanf("%lf, %lf, %lf", &a, &b, &c);
printf("%lfx^2 + %lfx + %lf = 0\n", a, b, c);
if(b * b - 4 * a * c > 0){
x1 = (-b - sqrt(b * b - 4 * a * c)) / 2;
x2 = (-b + sqrt(b * b - 4 * a * c)) / 2;
printf("x1 = %.2lf\n, x2 = %.2lf\n", x1, x2);
}
else if(b * b - 4 * a * c==0){
x1 = x2 = -b / 2;
printf("x1 = x2 = %.2lf\n", x1);
}else{
printf("此方程无解!");
}
return 0;
} |