#include<iostream>
using namespace std;

class Complex
{
public:
	Complex(double real = 0.0, double p_w_picpath = 0.0)
	{
		this->_real = real;
		_p_w_picpath = p_w_picpath;
	}
	Complex(const Complex &c)
	{
		_real = c._real;
		_p_w_picpath = c._p_w_picpath;
	}
	Complex& operator=(const Complex &c)
	{
		_real = c._real;
		_p_w_picpath = c._p_w_picpath;
		return *this;
	}
	bool operator>(const Complex &c)
	{
		double tmp1,tmp2;
		tmp1 = sqrt(pow(_real, 2) + pow(_p_w_picpath, 2));
		tmp2 = sqrt(pow(c._real, 2) + pow(c._p_w_picpath, 2));
		return tmp1 > tmp2;
	}
	bool operator==(const Complex &c)
	{
		return sqrt(pow(_real, 2) + pow(_p_w_picpath, 2)) == sqrt(pow(c._real, 2) + pow(c._p_w_picpath, 2));
	}
	bool operator>=(const Complex &c)
	{
		return ((*this > c) || (*this == c));
	}
	bool operator<(const Complex &c)
	{
		return sqrt(pow(_real, 2) + pow(_p_w_picpath, 2)) < sqrt(pow(c._real, 2) + pow(c._p_w_picpath, 2));
	}
	bool operator<=(const Complex &c)
	{
		return (*this < c) || (*this == c);
	}
	Complex operator+(const Complex &c)
	{
		Complex add;
		add._real = _real + c._real;
		add._p_w_picpath = _p_w_picpath + c._p_w_picpath;
		return add;
	}
	Complex operator-(const Complex &c)
	{
		Complex sub;
		sub._real = _real - c._real;
		sub._p_w_picpath = _p_w_picpath - c._p_w_picpath;
		return sub;
	}
	Complex operator*(const Complex &c)const//******
	{
		Complex mul;
		mul._real = _real*c._real - _p_w_picpath*c._p_w_picpath;
		mul._p_w_picpath = _real*c._p_w_picpath + _p_w_picpath*c._real;
		return mul;
	}
	Complex operator/(const Complex &c)******
	{
		Complex div;
		Complex c1;
		c1._real = c._real;
		c1._p_w_picpath = (-1)*c._p_w_picpath;
		const Complex c2 = c*c1;//********************易错
		div._real = ((*this*c1)._real) / (c2._real);
		div._p_w_picpath = ((*this*c1)._p_w_picpath) / (c2._real);
		return div;
	}
	Complex operator+=(const Complex &c)
	{
		_real = _real + c._real;
		_p_w_picpath = _p_w_picpath + c._p_w_picpath;
		return *this;
	}
	Complex operator-=(const Complex &c)
	{
		_real = _real - c._real;
		_p_w_picpath = _p_w_picpath - c._p_w_picpath;
		return *this;
	}
	Complex operator++(int)//后置
	{
		Complex tmp(*this);
		_real++;
		_p_w_picpath++;
		return tmp;
	}
	Complex operator++()//前置
	{
		_real++;
		_p_w_picpath++;
		return *this;
	}
	Complex operator--(int)//后置
	{
		Complex tmp(*this);
		_real--;
		_p_w_picpath--;
		return tmp;
	}
	Complex operator--()//前置
	{
		_real--;
		_p_w_picpath--;
		return *this;
	}
	void Display()
	{
		if (_real != 0)
		{
			if (_p_w_picpath>0)
				cout << "Complex=" << _real << "+i" << _p_w_picpath << endl;
			else if (_p_w_picpath < 0)
				cout << "Complex=" << _real << "-i" << (_p_w_picpath)*(-1) << endl;
			else
				cout << "Complex=" << _real << endl;
		}
		else
		{
			if (_p_w_picpath>0)
				cout << "Complex=" << "i" << _p_w_picpath << endl;
			else if (_p_w_picpath < 0)
				cout << "Complex=" << "-i" << (_p_w_picpath)*(-1) << endl;
			else
				cout << "Complex=" << _real << endl;
		}
	}
  ~Complex()
	{
	}
private:
	double _real;
	double _p_w_picpath;
};

void Test()
{
        Complex c1(2,1);
	c1.Display();

	//Complex c2(c1);
	Complex c2=c1;
	c2.Display();

	Complex c3,c4;
	c4=c3 = c2;
	c3.Display();
	c4.Display();

	Complex c5(1,2);
	c5.Display();

	bool ret1 = c1 > c5;
	cout << ">   "<<ret1 << endl;

	bool ret2 = c1 == c5;
	cout << "==  " << ret2 << endl;

	bool ret3 = c1 >= c5;
	cout << ">=  " << ret3 << endl;

	bool ret4 = c1 < c5;
	cout << "<   " << ret4 << endl;

	bool ret5 = c1 <= c5;
	cout << "<=  " << ret5 << endl;

	Complex add = c1 + c5;
	add.Display();

	Complex sub = c1 - c5;
	sub.Display();

	Complex mul = c1 * c5;
	mul.Display();

	Complex div = c1 / c5;
	div.Display();

	(c1 += c5).Display();
	(c1 -= c5).Display();

	(c1++).Display();
	(++c5).Display();

	(c1--).Display();
	(--c5).Display();
}
int main()
{
        Test();
	system("pause");
	return 0;
}