class complex //创建一个复数类.
{
public:
complex()
{
real=0;
imag=0;
}
complex(double r,double i)
{
real=r;
imag=i;
}
complex operator +(const complex &c)
{
return complex(real+c.real,imag+c.imag);
}
complex operator -(const complex &c)
{
return complex(real-c.real,imag-c.imag);
}
complex operator *(const complex &c)
{
return complex(real*c.real-imag*c.imag,real*c.imag+imag*c.real);
}
complex operator /(const complex &c)
{
return complex((real*c.real+imag+c.imag)/(c.real*c.real+c.imag*c.imag),(imag*c.real-
real*c.imag)/(c.real*c.real+c.imag*c.imag));
}
}