标签:
4 1 1
x1=-0.125+0.484i x2=-0.125-0.484i
#include <stdio.h>
#include <math.h>
int
main()
{
float
a,b,c,t,x1,x2;
scanf
(
"%f%f%f"
,&a,&b,&c);
t=b*b-4*a*c;
if
(t>0)
{
x1=(
sqrt
(t)-b)/(2*a);
x2=(b+
sqrt
(t))/(2*a);
printf
(
"x1=%.3f x2=%.3f"
,x1,x2);
}
if
(t==0)
{
x1=-b/(2*a);
x2=x1;
printf
(
"x1=%.3f x2=%.3f"
,x1,x2);
}
if
(t<0)
{
printf
(
"x1=%.3f+%.3fi x2=%.3f-%.3fi"
,-b/(2*a),
sqrt
(-t)/(2*a),-b/(2*a),
sqrt
(-t)/(2*a));
}
}
标签:
原文地址:http://www.cnblogs.com/SSYYGAM/p/4211313.html