Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <math.h>
  4.  
  5. using namespace std;
  6.  
  7. class Complex;
  8.  
  9. class Pereche {
  10.     friend class Complex;
  11. private:
  12.     int a, b;
  13.  
  14. public:
  15.     Pereche(int aa, int bb) : a{ aa }, b{ bb } {
  16.     }
  17.     Pereche() {
  18.     }
  19. };
  20.  
  21. class Complex {
  22.     friend class Pereche;
  23.     Pereche m, n;
  24. public:
  25.    
  26.     Complex() {
  27.         cin >> m.a >> m.b >> n.a >> n.b;
  28.     }
  29.  
  30.     void afisare() {
  31.         cout << m.a << "+ " << m.b << "i\n";
  32.         cout << n.a << "+ " << n.b << "i\n";
  33.     }
  34.  
  35.     void suma() {
  36.         Pereche s;
  37.         s.a = m.a + n.a;
  38.         s.b = m.b + n.b;
  39.         cout << s.a << "+ " << s.b << "i\n";
  40.     }
  41.  
  42. };
  43.  
  44. int main() {
  45.    
  46.     Complex c;
  47.     c.afisare();
  48.     c.suma();
  49.     cout << endl;
  50.     cin.get();cin.get();
  51.  
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement