Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.44 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. class Box
  4. {
  5. public:
  6.     Box()
  7.         : m_a(new double), m_b(new double), m_c(new double)
  8.     {
  9.         *m_a = 1;
  10.         *m_b = 1;
  11.         *m_c = 1;
  12.     }
  13.  
  14.     Box(const Box& other)
  15.         : m_a(new double), m_b(new double), m_c(new double)
  16.     {
  17.         *m_a = other.a();
  18.         *m_b = other.b();
  19.         *m_c = other.c();
  20.     }
  21.  
  22.     ~Box()
  23.     {
  24.         m_a = nullptr;
  25.         m_b = nullptr;
  26.         m_c = nullptr;
  27.         delete m_a;
  28.         delete m_b;
  29.         delete m_c;
  30.     }
  31.  
  32.     double a() const { return *m_a; }
  33.     double b() const { return *m_b; }
  34.     double c() const { return *m_c; }
  35.  
  36.     void set_a(double a) { *m_a = a; }
  37.     void set_b(double b) { *m_b = b; }
  38.     void set_c(double c) { *m_c = c; }
  39.  
  40.     double get_volume() { return (*m_a) * (*m_b) * (*m_c); }
  41.  
  42. private:
  43.     double *m_a, *m_b, *m_c;
  44. };
  45.  
  46. int main()
  47. {
  48.     Box baseBox;
  49.  
  50.     double a, b, c;
  51.  
  52.     do
  53.     {
  54.         std::cin >> a >> b >> c;
  55.         Box box(baseBox);
  56.         box.set_a(a);
  57.         box.set_b(b);
  58.         box.set_c(c);
  59.  
  60.         if(box.get_volume() < 1)
  61.         {
  62.             std::cout << "Malak \n";
  63.         }
  64.         else if(box.get_volume() > 1 && box.get_volume() < 5)
  65.         {
  66.             std::cout << "Sreden \n";
  67.         }
  68.         else if(box.get_volume() > 5)
  69.         {
  70.             std::cout << "Golqm \n";
  71.         }
  72.     } while(a != 1 && b != 1 && c != 1);
  73.  
  74.     return 0;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement