求二次方程的解#include"stdio.h"#include"math.h"void main(){float a,b,c,p,q,x1,x2;scanf("%f,%f,%f\n",&a,&b,&c);p=sqrt(b*b-4*a*c)/2;q=-b/2;x1=p+q;x2=p-q;printf("x1=%1.1f,x2=%1.1f\n",x1,x2);}

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/20 20:17:13
求二次方程的解#include"stdio.h"#include"math.h"voidmain(){floata,b,c,p,q,x1,x2;scanf("%f,%f,%f\n",&a,&b,&c)

求二次方程的解#include"stdio.h"#include"math.h"void main(){float a,b,c,p,q,x1,x2;scanf("%f,%f,%f\n",&a,&b,&c);p=sqrt(b*b-4*a*c)/2;q=-b/2;x1=p+q;x2=p-q;printf("x1=%1.1f,x2=%1.1f\n",x1,x2);}
求二次方程的解
#include"stdio.h"
#include"math.h"
void main()
{
float a,b,c,p,q,x1,x2;
scanf("%f,%f,%f\n",&a,&b,&c);
p=sqrt(b*b-4*a*c)/2;
q=-b/2;
x1=p+q;
x2=p-q;
printf("x1=%1.1f,x2=%1.1f\n",x1,x2);
}

求二次方程的解#include"stdio.h"#include"math.h"void main(){float a,b,c,p,q,x1,x2;scanf("%f,%f,%f\n",&a,&b,&c);p=sqrt(b*b-4*a*c)/2;q=-b/2;x1=p+q;x2=p-q;printf("x1=%1.1f,x2=%1.1f\n",x1,x2);}
修改如下:
//---------------------------------------------------------------------------
#include"stdio.h"
#include"math.h"
void main()
{
float a,b,c,p,q,x1,x2;
scanf("%f,%f,%f",&a,&b,&c); /*注意这里*/
p=sqrt(b*b-4*a*c)/(2*a); /*注意这里*/
q=-b/(2*a); /*注意这里*/
x1=p+q;
x2=p-q;
printf("x1=%1.1f,x2=%1.1f\n",x1,x2);
}
//---------------------------------------------------------------------------
另外,应该考虑delta