a006.
一元二次方程式
| From: [218.168.40.176] |
發表日期
:
2008-09-11 10:59
#include
#include
int main(){
double a,b,c,d,x1,x2;
d = b * b - 4 * a * c;
while(scanf("%lf%lf%lf",&a,&b,&c) != EOF){
if(d > 0){
x1 = ((-1 * b) + sqrt(d))/(2 * a);
x2 = ((-1 * b) - sqrt(d))/(2 * a);
printf("Two different roots x1=%.0f , x2=%.0f\n",x1,x2);
}
else if (d == 0){
x1 = (-1 * b)/(2 * a);
printf("Two same roots x=%.0f\n",x1);
}
else
printf("No real root\n");
}
return 0;
}