Last updated on

【sdut-1161】C语言实验——一元二次方程Ⅰ


##sdut_1161->C语言实验——一元二次方程Ⅰ

原题地址:https://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Index/problemdetail/pid/1161.html

这道题虽然也是用公式法套公式

但是。。。delta 的情况没说清楚。。。容易让人误解

###代码君奉上:

#include <stdio.h>
#include <math.h>

//sdut 1161 
int main(void)
{
	double a,b,c;
	double delta,x1,x2;
	scanf("%lf %lf %lf",&a,&b,&c);
	delta = b*b - (4*a*c);

	x1 = (-b+sqrt(delta))/(2*a);
	x2 = (-b-sqrt(delta))/(2*a);
	if(x1>x2)
		printf("%.2lf %.2lf",x1,x2); 
	else
		printf("%.2lf %.2lf",x2,x1); 

	return 0;
}

//题目未描述清楚 
/*
ax^2 + bx + c = 0

1 5 -2  
0.35 -5.35 
*/