2009-04-04 12:25:59來源不明

一元二次方程式

/************************************************************/

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

上一篇:Eva 的回家作業

下一篇:判斷質數

2013-04-28 23:09:39

對啊

紅燒小名 2010-01-22 23:11:39

不好意思 請問一下 sqrt是代表開根號的意思嘛?