#25713: 參考一下就好 不要照抄照抄


s910251@student.cysh.cy.edu.tw (吳亮佑)


#include <stdio.h>

#include <math.h>

 

int main()

{

  int a,b,c,d;

  int x1,x2,x3;

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

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

 

  if(d>0)

  {

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

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

    printf("Two different roots x1=%d , x2=%d\n",x1,x2);

  }

  if(d=0)

  {

    x3= -b/(2*a);

    printf("Two same roots x=%d\n",x3);

  }

  if(d<0)

  {

    printf("No real root\n");

  }

return 0;

}

 

hi

#25723: Re:參考一下就好 不要照抄照抄


71087@stu.cchs.chc.edu.tw (~ pythOnia ChallengeR ~)


#include

#include

 

int main()

{

  int a,b,c,d;

  int x1,x2,x3;

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

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

 

  if(d>0)

  {

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

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

    printf("Two different roots x1=%d , x2=%d\n",x1,x2);

  }

  if(d=0)

  {

    x3= -b/(2*a);

    printf("Two same roots x=%d\n",x3);

  }

  if(d<0)

  {

    printf("No real root\n");

  }

return 0;

}

 

hi

雖然我是寫python的.....

但我發現這似乎是一元二次方程式吧??