70分救救我
查看原帖
70分救救我
797464
zfw100楼主2023/1/17 14:30
#include<bits/stdc++.h>
using namespace std;
int main(){
	double a,b,c;
	cin>>a>>b>>c;
	double x1=(-b+sqrt(b*b-4*a*c))/2/a;
	double x2=(-b-sqrt(b*b-4*a*c))/2/a;
	if(b*b-4*a*c<0){
		cout<<"No answer!";
	}else if(x1==x2){
		cout<<fixed<<setprecision(5)<<"x1=x2="<<x1;
	}else if(x1<x2){
		cout<<fixed<<setprecision(5)<<"x1="<<x1<<";x2="<<x2;
	}else if(x1>x2){
		cout<<fixed<<setprecision(5)<<"x2="<<x2<<";x1="<<x1;
	}
	return 0;
}

2023/1/17 14:30
加载中...