#10726: 請問我這個錯在哪 (C)


Linightz (Linightz)

學校 : Seneca College
編號 : 21107
來源 : [218.32.239.148]
最後登入時間 :
2019-04-12 14:44:32
a006. 一元二次方程式 | From: [123.192.179.77] | 發表日期 : 2016-02-25 23:37

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

int main()
{
int a,b,c;
while((scanf("%d %d %d",&a,&b,&c))!=EOF)
{
if(a==0 || ((b*b)-(4*a*c))<0)
printf("No real root\n");
else if( -b+sqrt(b*b-4*a*c) == -b-sqrt(b*b-4*a*c) )
printf("Two same roots x=%d\n", (-b-sqrt(b*b-4*a*c))/(2*a) );
else
printf("Two different roots x1=%d , x2=%d\n", (-b-sqrt(b*b-4*a*c))/(2*a), (-b+sqrt(b*b-4*a*c))/(2*a) );
}
return 0;
}

 
ZeroJudge Forum