//已知一元二次方程ax^2+bx+c=0,输入a、b、c,求出x;
#include <stdio.h>
#include <math.h>
void main()
{
float a,b,c;
scanf("%f%f%f",&a,&b,&c);
float m;
float x1;
float x2;
m = b*b-4*a*c;
if (m < 0)
printf("no solution");
else if (m == 0)
{
x1 = (-b) / (2*a);
printf("%f\n",x1);
}
else
{
x1 = (-b-sqrt(m)) / (2*a);
x2 = (-b+sqrt(m)) / (2*a);
printf("%f %f\n",x1,x2);
}
}

被折叠的 条评论
为什么被折叠?



