做个了ax^2+bx+c=0的计算编程,求指错
# include <stdio.h># include <math.h>
int main()
{ int a, b, c; float X1, X2, d; char ch;
do
{ clrscr();
printf("\n\n\t------------- ax^2+bx+c=0--------------\n");
printf("\n\tplease input a,b,c.(int)!\n");
printf("a="); scanf( "%f", &a );
printf("b="); scanf( "%f", &b );
printf("c="); scanf( "%f", &c );
if ( a==0 )
if ( b==0 )
if ( c==0 )
printf("\n\tThere are many root!\n");
else
printf("\n\tNo root!\n");
else
{
X1=(-1.0*c)/b;
X2==X1;
printf("\n\tX1=%f\n\tX2=%f",&X1,&X2 );
}
else
{
d=b*b-4.0*a*c;
if ( d==0 )
{
X1=-b/(2.0*a);
X2==X1;
printf("\n\tX1=%f\n\tX2=%f",&X1,&X2 );
}
else
if ( d>0 )
{
X1=(-b+sqrt(d))/2.0*a;
X2=(-b-sqrt(d))/2.0*a;
printf("\n\tX1=%f\n\tX2=%f",&X1,&X2);
}
else
{
X1=(-b+sqrt(-d))/2.0*a;
X2=(-b-sqrt(-d))/2.0*a;
printf("\n\tX1=%fi\n\tX2=%fi",&X1,&X2);
}
}
printf("\n\n\tContinue( Yes -- anykey / No -- 'n')?\n");
ch=getch();
if ( ch=='N' ) ch='n';
} while ( ch!='n' );
return 0;
}
我看了一下午无法解决- -