一元二次方程编译错误,想知道原因是什么/


#include
#include
double sqrt(double x)
int main()
{
    int a,b,c,x1,x2,dt;
    dt=b*b-(4*a*c);

while(scanf("%d%d%d",&a,&b,&c)!=EOF)
 {
     if(dt>=0)
        {   x1=(b+sqrt(dt))/2;
            x2=(-b+sqrt(dt))/2
            printf("YES\n");
            printf("%d%d",x1,x2);
        }
     else if(dt<0)
             {printf("NO");}

 }
}
//求一元二次方程的根
//这个代码为什么OJ网上编译错误,求大佬指点:)

double sqrt(double x)
x2=(-b+sqrt(dt))/2
这两行后面没有分号,如果还有错误可以把错误截图贴上,把代码弄完整!

dt=b * b-(4 * a * c);这句放到while里,运行这句的时候abc都没有赋值 。
scanf返回的是正确输入的参数数量。

img


OJ网站还是显示解答错误
这是修改后的代码

#include<stdio.h>
#include<math.h>
double sqrt(double x);
int main()
{
    int a,b,c,dt;
    float x1,x2;


while(scanf("%d%d%d",&a,&b,&c)!=EOF)
 {
     dt=(b*b-(4*a*c));
     if(dt>=0)
        {   x1=(b+sqrt(dt))/2;
            x2=(-b+sqrt(dt))/2;
            printf("YES\n");
            printf("%.2f %.2f",x1,x2);
        }
     else if(dt<0)
             {printf("NO");}

 }

}