SHARE
TWEET

Untitled

a guest Mar 20th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <conio.h>
  3. using namespace std;
  4.  
  5.  
  6.  
  7. class complex {
  8. private:
  9.     double real;
  10.     double imagine;
  11.     double bufer1;
  12.     double bufer2;
  13.  
  14. public:
  15.     complex();
  16.     complex(double a, double b);
  17.    
  18.     void operator+(complex x);
  19.     void operator-(complex x);
  20.     void operator*(complex x);
  21.     void operator/(complex x);
  22.     ~complex();
  23.        
  24.    
  25.     void printer();
  26.  
  27. };
  28. complex :: complex() {
  29.     real = 0;
  30.     imagine = 0;
  31.    
  32.  
  33. }
  34. complex::~complex() {
  35.     cout << "Bye-Bye" << endl;
  36. }
  37. complex::complex(double a, double b) {
  38.     real = a;
  39.     imagine = b;
  40. }
  41. void complex::operator+(complex x) {
  42.     bufer1 = x.real + real;
  43.     bufer2 = x.imagine + imagine;
  44. }
  45. void complex::operator-(complex x) {
  46.     bufer1 = real   - x.real;
  47.     bufer2 = imagine - x.imagine;
  48.  
  49. }
  50. void complex::operator*(complex x) {
  51.     bufer1 = real * (x.real) - imagine * x.imagine;
  52.     bufer2 = real * (x.imagine) + imagine * x.real;
  53. }
  54. void complex::operator/(complex x) {
  55.     bufer1 = (real*x.real - imagine * x.imagine) / (x.real*x.real + x.imagine*x.imagine);
  56.     bufer2 = (imagine * x.real - real * x.imagine) / (x.real*x.real + x.imagine*x.imagine);
  57. }
  58. void complex::printer() {
  59.     cout << bufer1 << "+" << "i*" << bufer2 << endl;
  60. }
  61. int main() {
  62.     double a, b,c,d;
  63.     cin >> a >> b;
  64.     //complex first;
  65.     complex *first = new complex(a,b);
  66.     cin >> c >> d;
  67.     //complex second;
  68.     complex *second = new complex(c, d);
  69.     //first.printer();
  70.  
  71.     cout << "summa" << endl;
  72.     first = first+*second;
  73.     first->printer();
  74.     //delete first;
  75.     //complex *first = new complex(a, b);
  76.    
  77.     cout << "minus" << endl;
  78.     first->minus(*second);  
  79.     first->printer();
  80.     //delete first;
  81.     //complex *first = new complex(a, b);
  82.  
  83.     cout << "mnoji" << endl;
  84.     first->mult(*second);
  85.     first->printer();
  86.     //delete first;
  87.     //complex *first = new complex(a, b);
  88.  
  89.     cout << "del" << endl;
  90.     first->del(*second);
  91.     first->printer();
  92.     //complex first(a, b);
  93.  
  94.  
  95.     delete first;
  96.     delete second;
  97.  
  98.     complex *third = new complex();
  99.     _getch();
  100. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top