#11199: 測試執行未過 請大大幫忙看看哪裡有問題


benten95187 (初心者)


#include<stdio.h>
#include<math.h>

int main(){

while(1){
int a,b,c;
float d,x1,x2;

scanf("%d%d%d",&a,&b,&c);

d = (b*b)-(4*a*c);

x1 = (-b +sqrt(d)) / (2*a);
x2 = (-b -sqrt(d)) / (2*a);

 

if(x1 != x2 && d >= 0)printf("Two different roots x1=%d x2=%d",(int)x1,(int)x2);
if(x1 == x2 && d >= 0)printf("Two same roots x=%d",(int)x1);
if(d < 0)printf("No real root");

printf("\n");
}
}