方程分解
代码呈现
#include <stdio.h>
#include <math.h>
int main()
{
double a = 0.0;
double b = 0.0;
double c = 0.0;
while (~scanf("%lf %lf %lf", &a, &b, &c))
{
double x1 = 0.0;
double x2 = 0.0;
if (a == 0.0)
printf("Not quadratic equation\n");
else
{
float d = b * b - 4 * a * c;
if (d == 0)
{
if ((-b) / (2 * a) == 0.0) //此判断解决在打印时出现-0.00的情况
printf("x1=x2=0.00\n");
else
printf("x1=x2=%0.2lf\n", (-b) / (2 * a));