#273: 答案對,但是卻一直出現WA


k8161221 (odthf)


這是我的程式碼,不知道哪裡有問題說?

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(void){
    double a,b,c,y,z;
    while(scanf("%lf %lf %lf", &a, &b, &c)!=EOF){
      if((b*b-4*a*c)>0){
        y=(-b+sqrt(b*b-4*a*c))/(2*a);
        z=(-b-sqrt(b*b-4*a*c))/(2*a);
        printf("Two different roots x1=%d,x2=%d\n",(int)y, (int)z);
      }else if((b*b-4*a*c)==0){
        y=(-b+sqrt(b*b-4*a*c))/(2*a);
        printf("Two same roots x=%d\n",(int)y);
      }
      else{
        printf("No real root\n");
      }
   }
   return 0;
}

#276: Re:答案對,但是卻一直出現WA


debugger (殺蟲劑)


這是我的程式碼,不知道哪裡有問題說?

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(void){
    double a,b,c,y,z;
    while(scanf("%lf %lf %lf", &a, &b, &c)!=EOF){
      if((b*b-4*a*c)>0){
        y=(-b+sqrt(b*b-4*a*c))/(2*a);
        z=(-b-sqrt(b*b-4*a*c))/(2*a);
        printf("Two different roots x1=%d,x2=%d\n",(int)y, (int)z);
      }else if((b*b-4*a*c)==0){
        y=(-b+sqrt(b*b-4*a*c))/(2*a);
        printf("Two same roots x=%d\n",(int)y);
      }
      else{
        printf("No real root\n");
      }
   }
   return 0;
}

很抱歉... 系統有點小錯... 現在可以看看為什麼 WA 了... :)