a006.
一元二次方程式
| From: [114.33.95.21] |
發表日期
:
2015-05-23 19:17
#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;
}