#include<stdio.h> #include<math.h> int main() { float a,b,c,t=0,k=0,s=0,f=0; float x1,x2; scanf("%f %f %f",&a,&b,&c); t=b*b-4*a*c; if(t>0) { s=sqrt(t) x1=(-b+s)/(2*a); x2=(-b-s)/(2*a); printf("%.2f %.2f",x1,x2); } if(t<0) { k=sqrt(-t)/2*a; f=-b/(2*a); printf("%.2f+%.2fi %.2f-%.2fi",f,k,f,k); } return 0; } |
Double click to view unformatted code.