#9857: 哪裡出問題了?


f0303224 (Google)


#include <stdio.h>
#include <math.h>
int main(void)
{
int a, b, c, t, s, r1, r2, i;
while(scanf("%d%d%d",&a, &b, &c)!=EOF) { 
t = b * b - 4*a*c;
if(t<0)
printf("No real root\n");
else if(t==0)
printf("Two same roots x=%d\n",-b/(2*a));
else{
s = sqrt(t);
r1 = (-b+s)/(2*a);
r2 = (-b-s)/(2*a);
}
printf("Two different roots x1=%d , x2=%d\n",r1,r2);
return 0;
}