1 条题解
-
112209水宇辰 (12209水宇辰) LV 9 @ 2021-12-04 11:23:41
#include<iostream> #include<cstdio> #include<cmath> using namespace std; int main() { double a,b,c,d,x1,x2; cin>>a>>b>>c; d=b*b-4*a*c; if(d==0) { x1=-b/(2*a); printf("x1=x2=%0.5f",x1); } if(d>0) { x1=(-b+sqrt(d))/(2*a); x2=(-b-sqrt(d))/(2*a); printf("x1=%0.5f;x2=%0.5f",x1,x2); } if(d<0) { x1=-b/(2*a); if (x1==0) x1=0; x2=sqrt(-d)/(2*a); printf("x1=%0.5f+%0.5fi;x2=%0.5f-%0.5fi",x1,x2,x1,x2); } }
- 1
信息
- ID
- 2349
- 难度
- 1
- 分类
- (无)
- 标签
- 递交数
- 66
- 已通过
- 41
- 通过率
- 62%
- 被复制
- 2
- 上传者