fork(2) download
  1. #include <iostream>
  2. #include <complex>
  3.  
  4. int main()
  5. {
  6. std::complex<double> a = 3.0;
  7. std::complex<double> b = 2.0;
  8. std::complex<double> c = 1.0;
  9.  
  10. std::complex<double> d = sqrt(pow(b,2)- 4.0*a*c);
  11. std::cout << "The answers are "
  12. << (-b + d)/(2.0*a) << " and "
  13. << (-b - d)/(2.0*a) << '\n';
  14. }
  15.  
Success #stdin #stdout 0.02s 2812KB
stdin
Standard input is empty
stdout
The answers are (-0.333333,0.471405) and (-0.333333,-0.471405)