一本通1058

//qf
#include <bits/stdc++.h>
#define f(i,j,n) for(register int i=j;i<=n;i++)
using namespace std;
typedef long long ll;
const double x1=1e-12;
const double x2=1e-6;
inline ll read(){
	ll x=0;
	int f=1;
	char ch=getchar();
	while(!isdigit(ch)) {
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(isdigit(ch)) x=(x<<1)+(x<<3)+ch-48,ch=getchar();
	return x*f;
}
signed main(){
	double a,b,c,y1,y2,d; 
    cin>>a>>b>>c;
    d=b*b-4*a*c;
    if(d<0 and fabs(d)>x1) printf("No answer!
");
    else if(fabs(d)<x1) {
        y1=-b/(2*a);
        if(fabs(y1)<x2) printf("x1=x2=%.5lf
",0);
        else printf("x1=x2=%.5lf
",y1);
    }
    else{
        y1=(-b+sqrt(d))/(2*a),y2=(-b-sqrt(d))/(2*a);
        if(fabs(y1)<x2)	y1=fabs(y1);
        if(fabs(y2)<x2)	y2=fabs(y2);
        if(y1<y2) printf("x1=%.5lf;x2=%.5lf",y1,y2);
        else printf("x1=%.5lf;x2=%.5lf",y2,y1);
    }
    return 0;
}
不存在十全十美的文章 如同不存在彻头彻尾的绝望
原文地址:https://www.cnblogs.com/qf-breeze/p/10667580.html