View Code of Problem 42

#include<stdio.h>
#include<math.h>
int main()
{
	double a,b,c;
	scanf("%lf %lf %lf",&a,&b,&c);
	double t,x1,x2,m1,m2;
	t=pow(b,2)-4*a*c;
//	if(t>0)
//	{
		t=sqrt(t);
		m1=(-b+t)/(2*a);
		m2=(-b-t)/(2*a);
		if(m1>=m2)
		{
			x1=m1;
			x2=m2;
		}
		else
		{
			x1=m2;
			x2=m1;
		}
		printf("%.2f %.2f",x1,x2);
//	}
	return 0;
}

Double click to view unformatted code.


Back to problem 42