|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include "stdio.h"
#include "math.h"
int p1(double a,double b,double root);
int p2(double a,double b);
int p3(double a,double b,double root);
int main()
{
double a,b,c,root;
scanf("%lf %lf %lf",&a,&b,&c);
root=(double)pow(b,2)-4*a*c;
if(root>0)
p1(a,b,root);
else if(root=0)
p2(a,b);
else
p3(a,b,root);
return 0;
}
int p1(double a,double b,double root)
{
printf("x1=%.3lf x2=%.3lf",-b/(2*a)+(double)pow(root,0.5)/(2*a),-b/(2*a)-(double)pow(root,0.5)/(2*a));
}
int p2(double a,double b)
{
printf("x1=%.3lf x2=%.3lf",-b/(2*a),-b/(2*a));
}
int p3(double a,double b,double root)
{
double s1,s2;
s1=-b/(2*a);
s2=(double)pow(-root,0.5)/(2*a);
printf("x1=%.3lf+%.3lfi x2=%.3lf-%.3lfi",s1,s2,s1,s2);
}
可以看出我这里出了什么问题吗?为什么有的地方输出显示0.0000 |
|