信息学奥赛一本通oj
题目链接
WA了一个点
下面是代码
#include<iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
cout<<setprecision(5)<<fixed;
double a,b,c;
double x1,x2;
double d;
cin>>a>>b>>c;
d=b*b-4*a*c;
if(d<0){
cout<<"No answer!";
return 0;
}
if(d==0){
x2=x1=((0-b)+sqrt(d))/(2*a);
cout<<"x1=x2="<<x1;
}else{
x1=((0-b)+sqrt(d))/(2*a);
x2=((0-b)-sqrt(d))/(2*a);
if(x1<x2){
cout<<"x1="<<x1<<";"<<"x2="<<x2;
}else{
cout<<"x1="<<x2<<";"<<"x2="<<x1;
}
}
return 0;
}