Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- class Complex
- {
- private:
- double re, im;
- public:
- Complex()
- {
- };
- Complex(double r, double i)
- {
- re = r;
- im = i;
- }
- Complex operator + (const Complex &c)
- {
- return Complex(re + c.re, im + c.im);
- }
- Complex operator - (const Complex &c)
- {
- return Complex(re - c.re, im - c.im);
- }
- Complex operator * (const Complex &c)
- {
- return Complex(re * c.re - im * c.im, re * c.im + im * c.re);
- }
- void print()
- {
- cout << "Deistvitelnoe " << re << "\tMnimoe " << im<< endl;
- }
- };
- int main()
- {
- Complex a(1,1);
- Complex b(1,2);
- Complex c(0,1);
- cout << "a = ";
- a.print();
- cout << "b = ";
- b.print();
- cout << "c = ";
- c.print();
- Complex sum = ((a*a) - (b*b*b) - (c));
- cout << "Answer is: ";
- sum.print();
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement