Advertisement
Guest User

кОмплЕксные числа

a guest
Jan 23rd, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. class Complex
  7. {
  8.  
  9. private:
  10.     double re, im;
  11.  
  12. public:
  13.     Complex()
  14.     {
  15.     };
  16.     Complex(double r, double i)
  17.     {
  18.         re = r;
  19.         im = i;
  20.     }
  21.     Complex operator + (const Complex &c)
  22.     {
  23.         return Complex(re + c.re, im + c.im);
  24.     }
  25.     Complex operator - (const Complex &c)
  26.     {
  27.         return Complex(re - c.re, im - c.im);
  28.     }
  29.     Complex operator * (const Complex &c)
  30.     {
  31.         return Complex(re * c.re - im * c.im, re * c.im + im * c.re);
  32.     }
  33.     void print()
  34.     {
  35.         cout << "Deistvitelnoe " << re << "\tMnimoe " << im<< endl;
  36.     }
  37. };
  38.  
  39. int main()
  40. {
  41.     Complex a(1,1);
  42.     Complex b(1,2);
  43.     Complex c(0,1);
  44.     cout << "a =  ";
  45.     a.print();
  46.     cout << "b =  ";
  47.     b.print();
  48.     cout << "c =  ";
  49.     c.print();
  50.  
  51.     Complex sum = ((a*a) - (b*b*b) - (c));
  52.      
  53.     cout << "Answer is: ";
  54.  
  55.     sum.print();
  56.  
  57.     system("pause");
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement