#include<iostream> #include<iomanip> #include<string> #include<algorithm> #include<math.h> using namespace std; int main(){ int a,b,c,temp; double x1,x2; scanf("%d %d %d",&a,&b,&c); temp=b*b-4*a*c; if(temp<0){ return -1; } else{ x1=(-b+sqrt(temp))/(2*a); x2=(-b-sqrt(temp))/(2*a); printf("%.2f %.2f",x1,x2); } return 0; } |
Double click to view unformatted code.