a006.
一元二次方程式
| From: [111.243.14.188] |
發表日期
:
2013-05-18 16:43
#include<cstdio>
#include<cmath>
int main(){
int a, b, c, D;
while(scanf("%d%d%d", &a, &b, &c) != EOF){
D=b*b-4*a*c;
if (D > 0){
printf("Two different roots x1=%d , x2=%d\n", (sqrt(D)+(-b))/(2*a), ((-b)-sqrt(D))/(2*a));
}
else if (D == 0){
printf("Two same roots x=%d\n", (-b)/2*a);
}
else{
printf("No real root\n");
}
}
}