70分,不知道哪里错了
查看原帖
70分,不知道哪里错了
821037
Lichengxuan377楼主2023/4/30 16:15
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;

int main(){
	double a,b,c;
	cin >> a >> b >> c;
	double d = b*b-4*a*c;
	double x1,x2;
	if(d > 0){
		x1 = (-b + sqrt(d)) / (2*a);
		x2 = (-b - sqrt(d)) / (2*a);
		cout << "x1=" << fixed << setprecision(5) << x1 << ";x2=" << fixed << setprecision(5) << x2 << endl;
		return 0;
	}
	else if(d == 0){
		x1 = (-b + sqrt(d)) / (2*a);
		cout << "x1=x2=" << fixed << setprecision(5) << x1 << endl;
		return 0;
	}
	else{
		cout << "No answer!";
	}
	return 0;
}
2023/4/30 16:15
加载中...