社区讨论
70分,蒟蒻求助
B2053求一元二次方程参与者 2已保存回复 2
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 2 条
- 当前快照
- 1 份
- 快照标识符
- @lo90e9xf
- 此快照首次捕获于
- 2023/10/28 03:31 2 年前
- 此快照最后确认于
- 2023/10/28 03:31 2 年前
CPP
#include<bits/stdc++.h>
using namespace std;
double a,b,c;
double x1,x2;
int main(){
cin>>a>>b>>c;
if((b*b-4*a*c)<0){
cout<<"No answer!";
return 0;
}
x1=(sqrt(b*b-4*a*c)-b)/(2*a);
x2=(0-sqrt(b*b-4*a*c)-b)/(2*a);
if(x1<x2){
cout<<"x1=";
cout<<fixed<<setprecision(5)<<x1;
cout<<";x2=";
cout<<fixed<<setprecision(5)<<x2;
}else if(x1>x2){
cout<<"x2=";
cout<<fixed<<setprecision(5)<<x2;
cout<<";x1=";
cout<<fixed<<setprecision(5)<<x1;
}else{
cout<<"x1=x2=";
cout<<fixed<<setprecision(5)<<x1;
}
return 0;
}
```cpp
回复
共 2 条回复,欢迎继续交流。
正在加载回复...