// testcomplex.cpp
#include <iostream>
#include <complex>
using namespace std;
int main(void)
{
complex<double> z(1.0, 2.0), i(0.0,1.0);
cout << "z=" << z << endl;
cout << "z.real()=" << z.real() << ", real(z)=" << real(z) << endl;
cout << "z.imag()=" << z.imag() << ", imag(z)=" << imag(z) << endl;
cout << "abs(z)=" << abs(z) << endl;
cout << "conj(z)=" << conj(z) << endl;
z=z*i;
cout << "z=" << z << endl;
cout << "z.real()=" << z.real() << ", real(z)=" << real(z) << endl;
cout << "z.imag()=" << z.imag() << ", imag(z)=" << imag(z) << endl;
cout << "abs(z)=" << abs(z) << endl;
cout << "conj(z)=" << conj(z) << endl;
}
|