大家好,有个程序其代码如下:
#include <math.h> float x1,x2,disc,p,q; greater_than_zero(float a,float b) {x1=(-b+sqrt(disc))/(2*a); x2=(-b-sqrt(disc))/(2*a); } equal_than_zero(float a,float b) { x1=x2=(-b)/(2*a); } smaller_than_zero(float a,float b) { p=(-b)/(2*a>; q=sqrt(disc)/(2*a); } main() { float a,b,c; printf("\nInput a,b,c:"); scanf("%f,%f,%f",&a,&b,&c); printf("\nequation:%5.2f*x*x+%5.2f*x+%5.2f=0\n",a,b,c); disc=b*b-4*a*c; printf("root:\n"); if (disc>0) { greater_than_zero(a,b); printf("x1=%5.2f\tx2=%5.2f\n\n",x1,x2); } else if (disc=0) {equal_than_zero(a,b); printf("x1=%5.2f\tx2=%5.2f\n\n",x1,x2); } else {smaller_than_zero(a,b); printf("x1=%5.2f+%5.2fi\tx2=%5.2f-%5.2fi\n",p,q,p,q); } }
为什么最后在运行的时候会出现如图的提示啊,请高手教教我,不胜感激!!!
谢谢大家!!
----------------解决方案--------------------------------------------------------
float x1,x2,disc,p,q;
greater_than_zero(float a,float b)
{x1=(-b+sqrt(disc))/(2*a);
x2=(-b-sqrt(disc))/(2*a);
}
equal_than_zero(float a,float b)
{
x1=x2=(-b)/(2*a);
}
smaller_than_zero(float a,float b)
{
p=(-b)/(2*a>;
q=sqrt(disc)/(2*a);
}
main()
{
float a,b,c;
printf("\nInput a,b,c:");
scanf("%f,%f,%f",&a,&b,&c);
printf("\nequation:%5.2f*x*x+%5.2f*x+%5.2f=0\n",a,b,c);
disc=b*b-4*a*c;
printf("root:\n");
if (disc>0)
{
greater_than_zero(a,b);
printf("x1=%5.2f\tx2=%5.2f\n\n",x1,x2);
}
else if (disc=0)
{equal_than_zero(a,b);
printf("x1=%5.2f\tx2=%5.2f\n\n",x1,x2);
}
else
{smaller_than_zero(a,b);
printf("x1=%5.2f+%5.2fi\tx2=%5.2f-%5.2fi\n",p,q,p,q);
}
}
----------------解决方案--------------------------------------------------------
----------------解决方案--------------------------------------------------------
功能函数smaller_than_zero有语法错误
----------------解决方案--------------------------------------------------------
----------------解决方案--------------------------------------------------------