#include<stdio.h>
#include <math.h>
int main()
{
int a,b,c,d;
int num1,num2,num3;
while(scanf("%d%d%d",&a,&b,&c)!=EOF){
d=b*b-4*a*c;
if(d>0){
num1=(-1*b+sqrt(b*b-4*a*c))/2*a;
num2=(-1*b-sqrt(b*b-4*a*c))/2*a;
printf("\nTwo different roots x1=%d , x2=%d",num1,num2);
}
else if(d==0){
num3=(-1*b+sqrt(b*b-4*a*c))/2*a;
printf("\nTwo same roots x=%d",num3);
}
else if(d<0){
printf("\nNo real root");
}
}
return 0;
}
#include
#include
int main()
{
int a,b,c,d;
int num1,num2,num3;
while(scanf("%d%d%d",&a,&b,&c)!=EOF){
d=b*b-4*a*c;
if(d>0){
num1=(-1*b+sqrt(b*b-4*a*c))/(2*a);
num2=(-1*b-sqrt(b*b-4*a*c))/(2*a);
printf("\nTwo different roots x1=%d , x2=%d",num1,num2);
}
else if(d==0){
num3=(-1*b+sqrt(b*b-4*a*c))/(2*a);
printf("\nTwo same roots x=%d",num3);
}
else if(d<0){
printf("\nNo real root");
}
}
return 0;
}
#include<stdio.h>
#include <math.h>
int main()
{
int a,b,c,d;
int num1,num2,num3;
while(scanf("%d%d%d",&a,&b,&c)!=EOF){
d=b*b-4*a*c;
if(d>0){
num1=(-1*b+sqrt(b*b-4*a*c))/(2*a);
num2=(-1*b-sqrt(b*b-4*a*c))/(2*a);
printf("\nTwo different roots x1=%d , x2=%d",num1,num2);
}
else if(d==0){
num3=(-1*b+sqrt(b*b-4*a*c))/(2*a);
printf("\nTwo same roots x=%d",num3);
}
else if(d<0){
printf("\nNo real root");
}
}
return 0;
}
乘法和除法是同等級的,若是沒有括號,就是從左到右計算
至於前4個測資都有過,我猜是剛好a都是1吧~
然後第5個測資a應該是2或-2