一元二次方程求根,ax^2+bx+c=0,要讨论a,b是不是0,即使是虚数根也要求出,想知道哪里错了.#include #include #include int main(){float a,b,c,d,m,n,x1,x2;scanf("%f %f %f",&a,&b,&c);if(a==0){if(b==0)printf("Not an equation");elsep
来源:学生作业帮助网 编辑:作业帮 时间:2024/06/15 01:03:20
![一元二次方程求根,ax^2+bx+c=0,要讨论a,b是不是0,即使是虚数根也要求出,想知道哪里错了.#include #include #include int main(){float a,b,c,d,m,n,x1,x2;scanf(](/uploads/image/z/1750420-28-0.jpg?t=%E4%B8%80%E5%85%83%E4%BA%8C%E6%AC%A1%E6%96%B9%E7%A8%8B%E6%B1%82%E6%A0%B9%2Cax%5E2%2Bbx%2Bc%3D0%2C%E8%A6%81%E8%AE%A8%E8%AE%BAa%2Cb%E6%98%AF%E4%B8%8D%E6%98%AF0%2C%E5%8D%B3%E4%BD%BF%E6%98%AF%E8%99%9A%E6%95%B0%E6%A0%B9%E4%B9%9F%E8%A6%81%E6%B1%82%E5%87%BA%2C%E6%83%B3%E7%9F%A5%E9%81%93%E5%93%AA%E9%87%8C%E9%94%99%E4%BA%86.%23include+%23include+%23include+int+main%28%29%7Bfloat+a%2Cb%2Cc%2Cd%2Cm%2Cn%2Cx1%2Cx2%3Bscanf%28%22%25f+%25f+%25f%22%2C%26a%2C%26b%2C%26c%29%3Bif%28a%3D%3D0%29%7Bif%28b%3D%3D0%29printf%28%22Not+an+equation%22%29%3Belsep)
一元二次方程求根,ax^2+bx+c=0,要讨论a,b是不是0,即使是虚数根也要求出,想知道哪里错了.#include #include #include int main(){float a,b,c,d,m,n,x1,x2;scanf("%f %f %f",&a,&b,&c);if(a==0){if(b==0)printf("Not an equation");elsep
一元二次方程求根,ax^2+bx+c=0,要讨论a,b是不是0,即使是虚数根也要求出,想知道哪里错了.
#include
#include
#include
int main()
{
float a,b,c,d,m,n,x1,x2;
scanf("%f %f %f",&a,&b,&c);
if(a==0)
{if(b==0)
printf("Not an equation");
else
printf("x=%.2f",(-c)/b);}
else
{d=b*b-4*a*c;
if(d>=0)
{x1=(-b+sqrt(d))/(2*a);
x2=(-b+sqrt(d))/(2*a);
printf("%.2f %.2f",x1,x2);
}
else{
m=-b/(2*a);
n=sqrt(-d)/(2*a);
printf("%.2f+%.2fi ",m,n);
printf("%.2f-%.2fi",m,n);}
}
return 0;
}
一元二次方程求根,ax^2+bx+c=0,要讨论a,b是不是0,即使是虚数根也要求出,想知道哪里错了.#include #include #include int main(){float a,b,c,d,m,n,x1,x2;scanf("%f %f %f",&a,&b,&c);if(a==0){if(b==0)printf("Not an equation");elsep
x1=(-b+sqrt(d))/(2*a);
x2=(-b-sqrt(d))/(2*a);