#include <stdio.h>
#include <math.h>
int main(){
int a;
int b;
int c;
int x1;
int x2;
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*b-4*a*c==0){
x1=-b/(2*a);
printf("Two same roots x=%d\n",x1);
}
else {x1=(-b+sqrt(b*b-4*a*c))/(2*a);
x2=(-b-sqrt(b*b-4*a*c))/(2*a);
printf("Two different roots x1=%d , x2=%d\n",x1,x2);
}
return 0;
}
}
自測顯示輸出短少是什麼意思呀?求大大們解答~
#include
#include
int main(){
int a;
int b;
int c;
int x1;
int x2;
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*b-4*a*c==0){
x1=-b/(2*a);
printf("Two same roots x=%d\n",x1);
}
else {x1=(-b+sqrt(b*b-4*a*c))/(2*a);
x2=(-b-sqrt(b*b-4*a*c))/(2*a);
printf("Two different roots x1=%d , x2=%d\n",x1,x2);
}
return 0;
}
}
自測顯示輸出短少是什麼意思呀?求大大們解答~
你要不要考慮吧return 0;放下面一點