fork download
  1. #include <iostream>
  2. #include <complex>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. double a, b, c;
  8.  
  9. while (cin >> a >> b >> c) {
  10. if (a ==0)
  11. continue;
  12.  
  13. complex<double> delta = b*b - 4 * a * c;
  14. complex<double> sqrtdel = sqrt(delta);
  15. cout << (-b - sqrtdel)*0.5/a << '\t' << (-b + sqrtdel)*0.5/a << endl;
  16. }
  17. return 0;
  18. }
Success #stdin #stdout 0s 3460KB
stdin
1 0 1
1 0 -1
1 -5 4
stdout
(-0,-1)	(0,1)
(-1,-0)	(1,0)
(1,-0)	(4,0)