C语言写二次函数#include #include #include int main() { float a,b,c;float x1,x2,m;printf("input number a=:");scanf("%f",&a);printf("input number b=:");scanf("%f",&b);printf("input number c=:");scanf("%f",&c);m=b*b-4*a*c;x1=(-b+sqrt(m))/(2*a);x2
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/26 08:31:54
C语言写二次函数#include #include #include int main() { float a,b,c;float x1,x2,m;printf("input number a=:");scanf("%f",&a);printf("input number b=:");scanf("%f",&b);printf("input number c=:");scanf("%f",&c);m=b*b-4*a*c;x1=(-b+sqrt(m))/(2*a);x2
C语言写二次函数
#include
#include
#include
int main()
{
float a,b,c;
float x1,x2,m;
printf("input number a=:");
scanf("%f",&a);
printf("input number b=:");
scanf("%f",&b);
printf("input number c=:");
scanf("%f",&c);
m=b*b-4*a*c;
x1=(-b+sqrt(m))/(2*a);
x2=(-b-sqrt(m))/(2*a);
if(m>=0){
if(m>0){
printf("两根\n");
\x05printf("x1=%f\n",x1);
\x05printf("x2=%f\n",x2);}
else
\x05printf("一根\n");
\x05printf("x1=x2=%f\n",x1);}
else
printf("无根\n");
system("PAUSE");
return 0; }
输入0,3,2显示出x1=-1.#IND00,x2=-1.#INF00,求修改.
C语言写二次函数#include #include #include int main() { float a,b,c;float x1,x2,m;printf("input number a=:");scanf("%f",&a);printf("input number b=:");scanf("%f",&b);printf("input number c=:");scanf("%f",&c);m=b*b-4*a*c;x1=(-b+sqrt(m))/(2*a);x2
#include
#include
#include
int main()
{
float a,b,c;
float x1,x2,m;
printf("input number a=:");
scanf("%f",&a);
printf("input number b=:");
scanf("%f",&b);
printf("input number c=:");
scanf("%f",&c);
m=b*b-4*a*c;
if(m>=0&&a!=0){
if(m>0){
x1=(-b+sqrt(m))/(2*a);
x2=(-b-sqrt(m))/(2*a);
printf("两根\n");
printf("x1=%f\n",x1);
printf("x2=%f\n",x2);}
else
printf("一根\n");
printf("x1=x2=%f\n",x1);}
else
{
if(a=0 &&b!=0) printf("根是x=-c/b");
if(a=0&&b=0) printf("为常函数");
if(a!=0) printf("无根\n");
}
system("PAUSE");
return 0; }