#include <stdio.h>
#include <math.h>
int main()
{
float a=0;
float b=3;
float c=2;
float x1,x2;
float m=b*b-4*a*c;
if(a==0)
{
x1=-(c/b);
printf("该函数不是一元二次函数\n");
printf("x = %lf\n",x1);
}
else
{
if(m==0)
{
printf("该函数有两个相等的根");
x1=x2=((-b)+sqrt(m))/(2*a);
}
else if(m<0)
{
printf("该函数有两个共轭根\n");
}
else
{
printf("该函数有两个不相等的根\n");
x1=((-b)+sqrt(m))/(2*a);
x2=((-b)-sqrt(m))/(2*a);
printf("x1 = %lf x2 = %lf",x1,x2);
}
}
return 0;
}
#include <math.h>
int main()
{
float a=0;
float b=3;
float c=2;
float x1,x2;
float m=b*b-4*a*c;
if(a==0)
{
x1=-(c/b);
printf("该函数不是一元二次函数\n");
printf("x = %lf\n",x1);
}
else
{
if(m==0)
{
printf("该函数有两个相等的根");
x1=x2=((-b)+sqrt(m))/(2*a);
}
else if(m<0)
{
printf("该函数有两个共轭根\n");
}
else
{
printf("该函数有两个不相等的根\n");
x1=((-b)+sqrt(m))/(2*a);
x2=((-b)-sqrt(m))/(2*a);
printf("x1 = %lf x2 = %lf",x1,x2);
}
}
return 0;
}