计算一元二次方程的两个实根 x1,x2
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
float a,b,c,temp,x1,x2;
printf("please input number:");
scanf("%f,%f,%f",&a,&b,&c);
temp = sqrt(b*b - 4*a*c);
if(temp > 0)
{
x1 = ((-b)+temp)/(2*a);
x2 = (b+temp)/(2*a);
printf("the value of x1 and x2 is :%d, %d\n",x1,x2);
}
else
printf("the value of x1 and x2 is error\n");
return 0;
}