#include "stdio.h" #include "math.h" void main() { double a,b,c,x1,x2,p,q,dis; printf("输入abc的值\n"); scanf("a=%lf b=%lf c=%lf",&a,&b,&c); dis=sqrt(b*b-4*a*c); p=-b/(2*a); q=dis/(2*a); x1=p+q; x2=p-q; printf("一元二次方程的解为:\n"); printf("x1=%5.2lf\nx2=%5.2lf\n",x1,x2); }