#include<stdio.h>
#include<math.h>
#define b2 pow(b,2)
#define b1 (4*a*c)
#define dat (b2-b1)
main()
{
float a, b, c, x1, x2;
printf("Enter the values of a,b, and c:");
scanf("%f\n%f\n%f",&a,&b,&c);
if(dat>=0)
{
x1=(-b+sqrt(dat))/2*a;
x2=(-b-sqrt(dat))/2*a;
printf("%f,%f",x1,x2);
}
else
{
printf("This equation has no solution");
}
}
一元二次方程求解---C语言
最新推荐文章于 2024-06-17 00:58:23 发布