#include<stdio.h>
#include<math.h>
int main(void)
{
float a,b,c,d;
printf("Please enter the coefficients a,b,c:\n");
scanf("%f,%f,%f",&a,&b,&c);
d=b*b-4*a*c;
if(d>=0)
printf("x1=%.4f, x2=%.4f\n",(-b+sqrt(d))/(2*a),(-b-sqrt(d))/(2*a));
else
printf("error!方程无实数根");
return 0;
}
计算一元二次方程的根
于 2022-03-23 21:46:20 首次发布