|
|
@ -18,10 +18,14 @@ class cnumber {
|
|
|
|
signi = get_sign(i);
|
|
|
|
signi = get_sign(i);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cnumber operator+(const cnumber& that) {
|
|
|
|
cnumber operator+(const cnumber &that) {
|
|
|
|
cnumber z(that.r + this->r, that.i + this->i);
|
|
|
|
cnumber z(that.r + this->r, that.i + this->i);
|
|
|
|
return z;
|
|
|
|
return z;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cnumber operator*(const cnumber &that) {
|
|
|
|
|
|
|
|
cnumber z( (that.r * this->r ) - (that.i * this->i) , (that.r * this->i) + (this->r * that.i) );
|
|
|
|
|
|
|
|
return z;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
friend ostream &operator<<( ostream &os, const cnumber &z ) {
|
|
|
|
friend ostream &operator<<( ostream &os, const cnumber &z ) {
|
|
|
|
os << z.r << (z.signi ? '+' : '\0' ) << z.i << 'i';
|
|
|
|
os << z.r << (z.signi ? '+' : '\0' ) << z.i << 'i';
|
|
|
|