编辑代码

#include<stdio.h>
#include<math.h>
int main()
{
 void one(float a,float b,float c);
 void two(float a,float b,float c);
 void noroots(float a,float b,float c);
 float a,b,c,del;
 scanf("%f%f%f",&a,&b,&c);
 del=b*b-4*a*c;
 if(del>0)
 two(a,b,c);
 else if(del==0)
 one(a,b,c);
 else
 noroots(a,b,c);
 return 0;
 } 
 void one(float a,float b,float c)
 {
  float x1,x2;
  x1=x2=(-b)/(2*a); 
  printf("x1=x2=%.2f\n",x1); 
 }
 void two(float a,float b,float c)
 {
  float x1,x2,delta;
  delta=b*b-4*a*c;
  x1=((-b)+sqrt(delta))/(2*a);
  x2=((-b)-sqrt(delta))/(2*a);
   printf("x1=%.2f\nx2=%.2f\n",x1,x2);
}
void noroots(float a,float b,float c)
 {
 float delta,realpart,imagepart;
  delta=-(b*b-4*a*c);
  realpart=(-b)/(2*a);
  imagepart=sqrt(delta)/(2*a);
  printf("the first imageroot=%0.2f+%0.2fi\n",realpart,imagepart);
  printf("the second imageroot=%0.2f-%.2fi\n",realpart,imagepart); 
 }