fork download
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5. double a = 1.0;
  6. double b = 3.0;
  7. double c = 3.0;
  8.  
  9. // real part
  10. double xr = -b / (2 * a);
  11.  
  12. // for imaginary part:
  13. double radicand = 4 * a * c - b * b;
  14. double denom = 2 * a;
  15.  
  16. std::cout << xr << " + √(" << radicand << ")/" << denom << "\n";
  17. }
Success #stdin #stdout 0s 4272KB
stdin
Standard input is empty
stdout
-1.5 + √(3)/2