请大家帮我做一下 谢谢大家了
----------------解决方案--------------------------------------------------------
#include<stdio.h>
#include<math.h>
main()
{float a,b,c,x,y;
clrscr();
printf("Enter coefficient for the quaderatic equation:\n");
printf("a:");
scanf("%f",&a);
printf("b:");
scanf("%f",&b);
printf("c:");
scanf("%f",&c);
if(b*b-4*a*c<0) printf("error");
else {if(a==0) {x=-b/c;
printf("The only solution is %g",x);
}
else {x=(-b+sqrt(b*b-4*a*c))/(2*a);
y=(-b-sqrt(b*b-4*a*c))/(2*a);
if(b*b-4*a*c==0) printf("The only solution is %g",x);
else{printf("The first solution is %g",x);
printf("\nThe second solution is %g",y);
}
}
}
}
----------------解决方案--------------------------------------------------------
还有虚根....
----------------解决方案--------------------------------------------------------
判断下b^2-4ac 分2种情况不就可以了,LZ不可以光靠别人啊!!
----------------解决方案--------------------------------------------------------