#include using namespace std; struct Complex // структура комплексного числа { Complex(double r, double i) : re(r), im(i) {} Complex operator+(Complex &other); Complex operator*(Complex &other); void Display( ) { cout << re << " + " << im << "i"<< endl; } private: double re, im; }; // Додавання комплексних чисел (a+bi)+(c+di)=(a+c)+(b+d)i Complex Complex::operator+( Complex &other ) { return Complex( re + other.re, im + other.im ); } // Множення * комплексних чисел (a+bi)*(c+di)=(ab-cd)+(ad+bc)i Complex Complex::operator*( Complex &other ) { return Complex(re * other.re - im * other.im, re * other.im - im * other.re); } int main() { Complex a = Complex(1., 2.); Complex b = Complex(3., 4.); Complex c = Complex(0., 0.); c = a + b; c.Display(); c = a * b; c.Display(); }