#include"stdio.h"
int a,b,c;
void shurunumber(void)
{
printf("Input your number");
scanf("%i%i%i",&a,&b,&c);
}
float yigen (float x1) //求X1的值
{
if (b*b-4*a*c>=0)
x1=(-b+sqart(b*b-4*a*c))/(2*a);
printf("%f",x1);
return x1;
}
float gen (float x2) //求X2的值
{
if (b*b-4*a*c>=0)
x2=(-b-sqart(b*b-4*a*c))/(2*a);
printf("%f",x2);
return x2;
}
float absl (float x)
{
if (x<0)
x=-x;
return x;
}
float sqart (float x) /*求平方跟*/
{
float guess=1.0;
while (absl(x/(guess*guess))!=1.0)
guess=(x/guess+guess)/2.0;
return guess;
}
int main(void)
{
float sqart (float x);
float yigen (float x1);
float gen (float x2);
if (b*b-4*a*c<0)
printf("方程根是复数");
getch();
return 0;
}
问题太多,请指教。谢!
求方程根程序错误