题目:http://lx.lanqiao.cn/problem.page?gpid=T429
一元二次方程求根公式
#include <cstdio>
#include <cmath>
int main(int argc, char** argv) {
double a, b, c;
scanf("%lf%lf%lf", &a, &b, &c);
double res= b*b-4*a*c;
if(res<0) {
printf("Error\n");
return 0;
}
double x1=( -b+sqrt( res))/2/a;
double x2=( -b-sqrt( res))/2/a;
printf("x1 = %.6lf\n", x1);
if( fabs( x1-x2)< 1e-8) return 0;
printf("x2 = %.6lf\n", x2);
return 0;
}