c语言问题!这段代码哪错了?

来源:百度知道 编辑:UC知道 时间:2024/05/13 19:33:13
#include <stdio.h>
#include <math.h>

main()
{
float a,b,c,x1,x2,disco,p,q;
scanf("a=%f,b=%f,c=%f\n",&a,&b,&c);

p=-b/(2*a);
q=sqrt(disco)/(2*a);
x1=p+q;
x2=p-q;
disco=b*b-4*a*c;
printf("\n\nx1=%5.2f\nx2=%5.2f\n",x1,x2);
return 0;
}

disco没有付值
/*路过帮一下,也没有改什么,只是移动了一句代码*/
#include <stdio.h>
#include <math.h>
main(){
float a,b,c,x1,x2,disco,p,q;
scanf("a=%f,b=%f,c=%f\n",&a,&b,&c);
disco=b*b-4*a*c;
p=-b/(2*a);
q=sqrt(disco)/(2*a);
x1=p+q;
x2=p-q;
printf("\n\nx1=%5.2f\nx2=%5.2f\n",x1,x2);
return 0;
}
如果这样的话,应该就可以了

#include <stdio.h>
#include <math.h>

main()
{
float a,b,c,x1,x2,disco,p,q;
scanf("%f%f%f",&a,&b,&c);

p=-b/(2*a);
q=sqrt(disco)/(2*a);
x1=p+q;
x2=p-q;
disco=b*b-4*a*c;
printf("\n\nx1=%5.2f\nx2=%5.2f\n",x1,x2);
return 0;
}