C语言,用三个函数分别求b^2-4ac大于等于小于0时,方程ax^2+bx+c的根,从主函数输入a,b,c值#include "stdio.h"double a,b,c,r,disc;double *p,*q;double m[2],n[2];double r1(double x,double y) {r=y/(2*x);return(r);}double r2(double x,do
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/20 03:35:16
C语言,用三个函数分别求b^2-4ac大于等于小于0时,方程ax^2+bx+c的根,从主函数输入a,b,c值#include "stdio.h"double a,b,c,r,disc;double *p,*q;double m[2],n[2];double r1(double x,double y) {r=y/(2*x);return(r);}double r2(double x,do
C语言,用三个函数分别求b^2-4ac大于等于小于0时,方程ax^2+bx+c的根,从主函数输入a,b,c值
#include "stdio.h"
double a,b,c,r,disc;
double *p,*q;
double m[2],n[2];
double r1(double x,double y)
{
r=y/(2*x);
return(r);
}
double r2(double x,double y,double z)
{
\x05m[1]=(-y+sqrt(y*y-4*x*z))/(2*x);
\x05m[2]=(-y-sqrt(y*y-4*x*z))/(2*x);
\x05return(m[1]);
}
double r3(double x,double y,double z)
{
\x05n[1]=sqrt(y*y-4*x*z)/(2*x);
\x05n[2]=-y/(2*x);
\x05return(n[1]);
}
\x05
main()
{
scanf("%ld,%ld,%ld",a,b,c);
disc=b*b-4*a*c;
if (a
C语言,用三个函数分别求b^2-4ac大于等于小于0时,方程ax^2+bx+c的根,从主函数输入a,b,c值#include "stdio.h"double a,b,c,r,disc;double *p,*q;double m[2],n[2];double r1(double x,double y) {r=y/(2*x);return(r);}double r2(double x,do
//运行情况如下:
1,2,-3
1.000000,-3.000000Press any key to continue
//正确的程序如下:
#include "stdio.h"
double a,b,c,r,disc;
double *p,*q;
double m[2],n[2];
double r1(double x,double y)
{
r=y/(2*x);
return(r);
}
double r2(double x,double y,double z)
{
\x09m[0]=(-y+sqrt(y*y-4*x*z))/(2*x);
\x09m[1]=(-y-sqrt(y*y-4*x*z))/(2*x);
\x09return(m[1]);
}
double r3(double x,double y,double z)
{
\x09n[0]=sqrt(y*y-4*x*z)/(2*x);
\x09n[1]=-y/(2*x);
\x09return(n[1]);
}
\x09
int main()
{
scanf("%lf,%lf,%lf",&a,&b,&c);
disc=b*b-4*a*c;
if (fabs(a)