新人求教,这怎么出不来结果啊。。。
#include<stdio.h>#include<math.h>
void dayu(double,double,double);
void dengyu(double,double,double);
void xiaoyu(double,double,double);
int main()
{
double p,a,b,c;
scanf("%lf %lf %lf",&a,&b,&c);
p=b*b-4*a*c;
if(p>0)
dayu(a,b,c);
if(p=0)
dengyu(a,b,c);
if(p<0)
xiaoyu(a,b,c);
}
void dayu(double a,double b,double c)
{
double x1,x2,p;
p=b*b-4*a*c;
x1=(-b+sqrt(p))/(2*a);
x2=(-b-sqrt(p))/(2*a);
printf("x1=%.2lf , x2=%.2lf\n",x1,x2);
}
void dengyu(double a,double b,double c)
{
double x;
x=(-b)/(2*a);
printf("%.2lf",x);
}
void xiaoyu(double a,double b,double c)
{
printf("函数无解,请重新输入");
}