View Code of Problem 42

#include<stdio.h>
#include<math.h>
int main()
{
	double a,b,c,d;
	scanf("%lf%lf%lf",&a,&b,&c);
	d=b*b-4*a*c;
	if(d<0)
		printf("该方程无解\n");
	else if(fabs(d-0)<=1e-6)
		printf("%.2lf %.2lf\n", (-b+sqrt(d))/(2*a), (-b-sqrt(d))/(2*a));
	else
		printf("%.2lf %.2lf\n", (-b+sqrt(d))/(2*a), (-b-sqrt(d))/(2*a));

	return 0;
}

Double click to view unformatted code.


Back to problem 42