我的程序哪里出错啦?用函数求一元二次方程的根#include#includefloat yishigen(float m,float n,float k);{float m,n,k; float x1,x2; x1=(-n+sqrt(k))/(2*m);x2=(-n-sqrt(k))/(2*m);printf("two shigen is x1=%3f and x2=%3f\n",x1,x2);}float d
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/27 23:08:38
我的程序哪里出错啦?用函数求一元二次方程的根#include#includefloat yishigen(float m,float n,float k);{float m,n,k; float x1,x2; x1=(-n+sqrt(k))/(2*m);x2=(-n-sqrt(k))/(2*m);printf("two shigen is x1=%3f and x2=%3f\n",x1,x2);}float d
我的程序哪里出错啦?用函数求一元二次方程的根
#include
#include
float yishigen(float m,float n,float k);
{float m,n,k;
float x1,x2;
x1=(-n+sqrt(k))/(2*m);
x2=(-n-sqrt(k))/(2*m);
printf("two shigen is x1=%3f and x2=%3f\n",x1,x2);
}
float denggen(m,n)
{float m,n;
float x;
x=-n/(2*m);
printf("denggen is x=%3f\n",x);
}
float xugen (m,n,k)
{float m,n,k;
float x,y;
x=-n/(2*m);
y=sqrt(-k)/(2*m);
printf("two xugen is x1=%3f+%3i\n and x2=%f-%3fi\n",x,y,x,y);
}
main()
{ float a,b,c,q;
printf("input a b c is:");
scanf("%f,%f,%f",&a,&b,&c);
printf("\n");
q=b*b-4*a*c;
if (q>0) yishigen (a,b,q);
else if (q==0) denggen (a,b);
else xugen (a,b,q);
}
我的程序哪里出错啦?用函数求一元二次方程的根#include#includefloat yishigen(float m,float n,float k);{float m,n,k; float x1,x2; x1=(-n+sqrt(k))/(2*m);x2=(-n-sqrt(k))/(2*m);printf("two shigen is x1=%3f and x2=%3f\n",x1,x2);}float d
函数没有返回值,函数的形式参数部分也不对,应该是fun(int a ,int b)
的形式