Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. // ConsoleApplication40.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы.
  2. //
  3.  
  4. #include <iostream>
  5. using namespace std;
  6. class Complex
  7. {
  8. private:
  9. double re, im;
  10. public:
  11. Complex()
  12. {
  13. re = im = 0;
  14. }
  15. Complex(double re, double im)
  16. {
  17. this->re = re;
  18. this->im = im;
  19. }
  20. void Show()
  21. {
  22. if (im > 0)
  23. {
  24. cout << re << "+" << im << "i" << endl;
  25. }
  26. else if (im == 0)
  27. {
  28. cout << re;
  29. }
  30. else
  31. {
  32. cout << re << im << "i" << endl;
  33. }
  34. }
  35. };
  36. int main()
  37. {
  38. Complex complex(2, -3);
  39. Complex complex1(2, 3);
  40. complex.Show();
  41. complex1.Show();
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement