当前位置: > c语言程序设计题目:计算一元二次方程的根...
题目
c语言程序设计题目:计算一元二次方程的根
【程序填空】
#include
//
else if(【?】)
{x1=(-b+sqrt(disc))/(2*a);
x2=(-b-sqrt(disc))/(2*a);
printf("has distinct real roots:%8.4f and %.4f ",x1,x2);
}
else
{realpart=-b/(2*a);
imagpart=sqrt(-disc)/(2*a);
printf("has complex roots: ");
printf("%8.4f=%.4fi ",realpart,imagpart);
printf("%8.4f-%.4fi ",realpart,imagpart);
}
}

提问时间:2020-11-07

答案
#include
//
else if(disc>0)
{
x1=(-b+sqrt(disc))/(2*a);
x2=(-b-sqrt(disc))/(2*a);
printf("has distinct real roots:%8.4f and %.4f ",x1,x2);
}
else
{
realpart=-b/(2*a);
imagpart=sqrt(-disc)/(2*a);
printf("has complex roots: ");
printf("%8.4f+%.4fi ",realpart,imagpart);
printf("%8.4f-%.4fi ",realpart,imagpart);
}
}
}
2 -3 -5
the equationhas distinct real roots:2.5000 and -1.0000
Press any key to continue
举一反三
已知函数f(x)=x,g(x)=alnx,a∈R.若曲线y=f(x)与曲线y=g(x)相交,且在交点处有相同的切线,求a的值和该切线方程.
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
版权所有 CopyRight © 2012-2019 超级试练试题库 All Rights Reserved.