求ax2+bx+c=0方程的根,a,b,c由键盘输入#include #include main(){float a=0;float b=0;float c=0;float disc=0;float x1=0;float x2=0;float p=0;float q=0;scanf("a=%f,b=%f,c=%f",&a,&b,&c);disc = b*b-4*a*c;if(disc>=0){p=-b/2*a;q=sqrt(
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/24 07:00:19
求ax2+bx+c=0方程的根,a,b,c由键盘输入#include #include main(){float a=0;float b=0;float c=0;float disc=0;float x1=0;float x2=0;float p=0;float q=0;scanf("a=%f,b=%f,c=%f",&a,&b,&c);disc = b*b-4*a*c;if(disc>=0){p=-b/2*a;q=sqrt(
求ax2+bx+c=0方程的根,a,b,c由键盘输入
#include
#include
main()
{
float a=0;
float b=0;
float c=0;
float disc=0;
float x1=0;
float x2=0;
float p=0;
float q=0;
scanf("a=%f,b=%f,c=%f",&a,&b,&c);
disc = b*b-4*a*c;
if(disc>=0)
{
p=-b/2*a;
q=sqrt(disc)/2*a;
x1=p+q;
x2=p-q;
printf("x1=%f,x2=%f",x1,x2);
}
else
{
printf("无解!");
}
}
设断点发现无论键盘输入什么a,b,c的值都是0
求ax2+bx+c=0方程的根,a,b,c由键盘输入#include #include main(){float a=0;float b=0;float c=0;float disc=0;float x1=0;float x2=0;float p=0;float q=0;scanf("a=%f,b=%f,c=%f",&a,&b,&c);disc = b*b-4*a*c;if(disc>=0){p=-b/2*a;q=sqrt(
输入语句改为scanf("%f,%f,%f",&a,&b,&c);
输入形式:1,1,1(注意,号不能省略)