stl中的complex

#include 
#include 

using namespace std;

int main()
{
    #ifndef ONLINE_JUDGE
        //freopen("d:\\OJ\\uva_in.txt", "r", stdin);
    #endif // ONLINE_JUDGE
	
	complex c1(4.0, 3.0);
	
	complex c2(polar(5.0, 0.75));
	
	cout << "c1:" << c1 << endl;
	cout << "c2:" << c2 << endl;
	
	cout << "c1:magnitude: " << abs(c1) 
		  << " (squred magnitude: " << norm(c1) << ") "
		  << " phase angle:" << arg(c1) << endl;
		  
	cout << "c2:magnitude: " << abs(c2) 
	     << " (squared magnitude: " << norm(c2) << ") "
		 << " phase angle: " << arg(c2) << endl;

	cout << "c1 conjugated: " << conj(c1) << endl;
	cout << "c2 conjugated: " << conj(c2) << endl;
	
	cout << "4.4 + c1 * 1.8:" << 4.4 + c1 * 1.8 << endl;
	
	cout << "c1 + c2: "
		 << c1 + complex(c2.real(), c2.imag()) << endl;
		 
	cout << "c1 += sqrt(c1): " << (c1 += sqrt(c1)) << endl;
	
    return 0;
}


你可能感兴趣的:(STL)