Advertisement
Guest User

Untitled

a guest
Mar 26th, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6. class Tcomplex
  7. {
  8. private:
  9.  
  10. float Re;
  11. float Im;
  12.  
  13. public:
  14. Tcomplex()
  15. {
  16. Re=0;
  17. Im=0;
  18. }
  19. Tcomplex(float Re)
  20. {
  21. this->Re=Re;
  22. Im=0;
  23. }
  24. Tcomplex(float Re,float Im)
  25. {
  26. this->Re=Re;
  27. this->Im=Im;
  28. }
  29.  
  30. Tcomplex show()
  31. {
  32. cout<<noshowpos<<Re<<showpos<<Im<<"j"<<endl;
  33. }
  34.  
  35. Tcomplex suma(Tcomplex B)
  36. {
  37. Tcomplex C;
  38. C.Re= Re+B.Re;
  39. C.Im= Im+B.Im;
  40. return C;
  41. }
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48. };
  49.  
  50.  
  51. int main()
  52. {
  53. Tcomplex A(2,4);
  54. Tcomplex B(6,-8);
  55.  
  56. A.suma(B).show();
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement