B2053 蒟蒻无奈--50分,求大佬指教(蒟蒻请求)
查看原帖
B2053 蒟蒻无奈--50分,求大佬指教(蒟蒻请求)
1547102
Narcissa楼主2025/7/3 21:46
#include<bits/stdc++.h>
using namespace std;
int main(){
	double a,b,c;
	cin >> a >> b >> c;
	double x1=(-b+sqrt(b*b-4.0*a*c))/(2*a);
	double x2=(-b-sqrt(b*b-4.0*a*c))/(2*a);
	if(x1==x2) cout << fixed << setprecision(5) << "x1=x2=" << x1;
	else if(x1!=x2){
		if(x1<x2) cout << fixed << setprecision(5) << "x1=" << x1 << ';' << "x2=" << x2;
		else cout << fixed << setprecision(5) << "x2=" << x2 << ';' << "x1=" << x1;
	}
	else cout << "No answer!";
	return 0;
}
2025/7/3 21:46
加载中...