如何编码一个方程式ax2+bx+c=0的根,分别考虑d=b2-4ac大于零等于零小于零这三种情况
1 回答
已采纳
一瞬儿光
TA贡献178条经验 获得超70个赞
#include<stdio.h> #include<math.h> void main() { double d,an,an2; d = b*b-4*a*c; if(d<0) { printf("answer is not exist"); } if(d=0) { an = -b/(2*a); printf("answer is %/f",an); } if(d>0) { d = sqrt(d); an = (-b+d)/(2*a); an2 = (-b-d)/(2*a); printf("answer1 is %/f and %f",an,an2); } }
- 1 回答
- 0 关注
- 1083 浏览
添加回答
举报
0/150
提交
取消