#include <iostream>
using namespace std;
class Complex
{
private:
	double real;
	double imag;
public:
	Complex()
	{
		real=0;imag=0;
	}
	Complex(double r,double i)
	{
		real=r;imag=i;
	}
	friend Complex operator*(Complex &c1,Complex &c2);
	Complex operator/(Complex &c);
	friend ostream& operator<<(ostream &output,Complex &c); 
};

Complex operator*(Complex &c1,Complex &c2)
{
	double t1,t2;
	t1=c1.real*c2.real-c1.imag*c2.imag;
	t2=c1.real*c2.imag+c1.imag*c2.real;
	return Complex(t1,t2);
}

Complex Complex::operator/(Complex &c)
{
	double t1,t2,demo;
	demo=c.real*c.real+c.imag*c.imag;
	if(demo!=0)
	{
	t1=(real*c.real+imag*c.imag)/demo;
	t2=(imag*c.real-real*c.imag)/demo;
	return Complex(t1,t2);
	}
}
ostream& operator<<(ostream &output,Complex &c)
{
	output<<"("<<c.real;
	if(c.imag>=0)
	output<<"+";
	output<<c.imag<<"i)"<<endl;
	return output;
}

void main()
{
	Complex c1(2,-3),c2(2,1),c3,c4;
	c3=c1*c2;
	c4=c1/c2;
	cout<<"复数的积:"<<c3<<endl;
	cout<<"复数的商:"<<c4<<endl;
}