fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <complex>
  4. using namespace std;
  5.  
  6. int main() {
  7. complex<int> c;
  8. int d;
  9. cout <<setw(12)<< "Complex" <<setw(12)<< "Conjugate" <<setw(12)<< "Cpx*conjg."<<setw(12)<< "Norm" <<setw(12) << "Abs" << setw(12)<<"dist" <<" abs<=dist? norm<=dist²"<<endl;
  10. while (cin>>c && cin>>d)
  11. cout <<setw(12)<< c <<setw(12)<< conj(c) <<setw(12)<< c*conj(c) <<setw(12)<< norm(c) <<setw(12) << abs(c) << setw(12)<<d<<(abs(c)<=d?" true ":" false ")<<(norm(c)<=d*d?" true ":" false ") <<endl;
  12. return 0;
  13. }
Success #stdin #stdout 0s 4368KB
stdin
(2,3) 3
stdout
     Complex   Conjugate  Cpx*conjg.        Norm         Abs        dist abs<=dist? norm<=dist²
       (2,3)      (2,-3)      (13,0)          13           3           3   true      false