class Complex
{
int real;
int imag;
public int Creal
{
get {return real;}
set {real = value;}
}
public int Cimag
{
get { return imag; }
set {imag = value;}
}
public Complex()
{
real = 0;
imag = 0;
}
public Complex(int a, int b)
{
real = a;
imag = b;
}
public override string ToString()
{
return real + "+" + imag + "i";
}
public static Complex operator +(Complex a, Complex b)
{
Complex temp = new Complex();
temp.real = a.real + b.real;
temp.imag = a.imag + b.imag;
return temp;
}
{
int real;
int imag;
public int Creal
{
get {return real;}
set {real = value;}
}
public int Cimag
{
get { return imag; }
set {imag = value;}
}
public Complex()
{
real = 0;
imag = 0;
}
public Complex(int a, int b)
{
real = a;
imag = b;
}
public override string ToString()
{
return real + "+" + imag + "i";
}
public static Complex operator +(Complex a, Complex b)
{
Complex temp = new Complex();
temp.real = a.real + b.real;
temp.imag = a.imag + b.imag;
return temp;
}
No comments:
Post a Comment