帮忙检查一下c语言的程序错在哪里,题目是求解一元二次方程.a*x*x+b*x+c=0
来源:学生作业帮 编辑:百度作业网作业帮 分类:综合作业 时间:2024/08/14 16:22:56
帮忙检查一下c语言的程序错在哪里,题目是求解一元二次方程.a*x*x+b*x+c=0
题目是求解一元二次方程.a*x*x+b*x+c=0
# include
# include
float x1,x2,disc,p,q;
greater_than_zero(float a,float b)
{x1=(-b+sqrt(disc))/(2*a);
x2=(-b-sqrt(disc))/(2*a);
}
equal_to_zero(float a,float b)
{
x1=x2=(-b)/(2*a);
}
smaller_than_zero(float a,float b)
{
p=-b/(2*a) ;
q=sqrt(disc)/(2*a);
}
void main ( )
{
float a,b,c;
printf("\nInput a,b,c:");
scanf("%f,%f,%f",&a,&b,&c);
printf("\nequation:%5.2f*x*x+%5.2f*x+%5.2f=0\n",a,b,c);
disc=b*b-4*a*c;
printf("root:\n");
if (disc>1e-6)
{
greater_than_zero(a,b);
printf("x1=%5.2f\tx2=%5.2f\n\n",x1,x2);
}
else if (fabs(disc)
题目是求解一元二次方程.a*x*x+b*x+c=0
# include
# include
float x1,x2,disc,p,q;
greater_than_zero(float a,float b)
{x1=(-b+sqrt(disc))/(2*a);
x2=(-b-sqrt(disc))/(2*a);
}
equal_to_zero(float a,float b)
{
x1=x2=(-b)/(2*a);
}
smaller_than_zero(float a,float b)
{
p=-b/(2*a) ;
q=sqrt(disc)/(2*a);
}
void main ( )
{
float a,b,c;
printf("\nInput a,b,c:");
scanf("%f,%f,%f",&a,&b,&c);
printf("\nequation:%5.2f*x*x+%5.2f*x+%5.2f=0\n",a,b,c);
disc=b*b-4*a*c;
printf("root:\n");
if (disc>1e-6)
{
greater_than_zero(a,b);
printf("x1=%5.2f\tx2=%5.2f\n\n",x1,x2);
}
else if (fabs(disc)
![帮忙检查一下c语言的程序错在哪里,题目是求解一元二次方程.a*x*x+b*x+c=0](/uploads/image/z/526380-60-0.jpg?t=%E5%B8%AE%E5%BF%99%E6%A3%80%E6%9F%A5%E4%B8%80%E4%B8%8Bc%E8%AF%AD%E8%A8%80%E7%9A%84%E7%A8%8B%E5%BA%8F%E9%94%99%E5%9C%A8%E5%93%AA%E9%87%8C%2C%E9%A2%98%E7%9B%AE%E6%98%AF%E6%B1%82%E8%A7%A3%E4%B8%80%E5%85%83%E4%BA%8C%E6%AC%A1%E6%96%B9%E7%A8%8B.a%2Ax%2Ax%2Bb%2Ax%2Bc%3D0)
1、从函数前要加void
2、getch()函数要包含在头文件中
别的没什么错误.
以下是我自己的程序,由于我写的内容多,所以包含了过多的头文件,你这个问题可以很好的解决.
#include "stdio.h"
#include "string.h"
#include
#include
#include
using namespace std;
float x1,x2,disc,p,q;
void greater_than_zero(float a,float b)
{
x1 = (-b + sqrt(disc))/(2*a);
x2 = (-b - sqrt(disc))/(2*a);
}
void equal_to_zero(float a,float b)
{
x1 = (-b)/(2*a);
x2 = x1;
}
void smaller_than_zero(float a,float b)
{
p = (-b)/(2*a) ;
q = sqrt(disc)/(2*a);
}
void main ( )
{
float a,b,c;
printf("\nInput a,b,c:");
scanf("%f,%f,%f",&a,&b,&c);
printf("\nequation:%5.2f*x*x+%5.2f*x+%5.2f=0\n",a,b,c);
disc=b*b-4*a*c;
printf("root:\n");
if (disc>1e-6)
{
greater_than_zero(a,b);
printf("x1=%5.2f\tx2=%5.2f\n\n",x1,x2);
}
else if (fabs(disc)
2、getch()函数要包含在头文件中
别的没什么错误.
以下是我自己的程序,由于我写的内容多,所以包含了过多的头文件,你这个问题可以很好的解决.
#include "stdio.h"
#include "string.h"
#include
#include
#include
using namespace std;
float x1,x2,disc,p,q;
void greater_than_zero(float a,float b)
{
x1 = (-b + sqrt(disc))/(2*a);
x2 = (-b - sqrt(disc))/(2*a);
}
void equal_to_zero(float a,float b)
{
x1 = (-b)/(2*a);
x2 = x1;
}
void smaller_than_zero(float a,float b)
{
p = (-b)/(2*a) ;
q = sqrt(disc)/(2*a);
}
void main ( )
{
float a,b,c;
printf("\nInput a,b,c:");
scanf("%f,%f,%f",&a,&b,&c);
printf("\nequation:%5.2f*x*x+%5.2f*x+%5.2f=0\n",a,b,c);
disc=b*b-4*a*c;
printf("root:\n");
if (disc>1e-6)
{
greater_than_zero(a,b);
printf("x1=%5.2f\tx2=%5.2f\n\n",x1,x2);
}
else if (fabs(disc)
帮忙检查一下c语言的程序错在哪里,题目是求解一元二次方程.a*x*x+b*x+c=0
求解一元二次方程a*x*x+b*x+c=0 用C语言写
谁会C语言,帮小弟做两题,1、编写程序求解一元二次方程a x +bx+c=0的根 2、编程求n!
一元二次方程求解的c语言程序
二次方程的求解公式x=? 帮忙给出推导过程. 是x关于a b c的一个公式,...
C语言 输入参数a,b,c,求一元二次方程a*x*x+b*x+c=0的根,结果保留2位小数.
一元二次方程:a(x-b)+c=0
有关等差数列的题目,设一元二次方程(b-c)x2+(c-a)x+(a-b)=0有两个相等实根,求证:a,b,c为等差数列
解一元二次方程方程(b-c)x²-(c-a)x+(a-b)=0
求一元二次方程 y=a*x*x+b*x+c的系数a,b,
已知a、b、c是三角形ABC的三边,且一元二次方程x²+2(b-c)X+(c-a)(a-b)=0,有两个实数根
已知a,b,c是△ABC的三边,x^2-2(a+b)x+c^2-2ab=0是关于x的一元二次方程.