SHARE
TWEET

Untitled

a guest May 19th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "Array.h"
  2. class Decimal :
  3.     public Array
  4. {
  5. private:
  6.  
  7. public:
  8.     Decimal();
  9.     Decimal(const Decimal &other);
  10. public:
  11.     void read();
  12.     void write();
  13.  
  14.     void sum(Array *sec, Array *result) override;       // Сумма
  15.     void sub(Array *sec, Array *result) override;       // Разность
  16.     void prod(Array *sec, Array *result) override;      // Произведение
  17.     void div(Array *sec, Array *result) override;       // Частное
  18.  
  19.     Decimal operator = (const Decimal & other)
  20.     {
  21.         this->_array = other._array;
  22.         this->size = other.size;
  23.     }
  24.     Decimal operator + (const Decimal & other)
  25.     {
  26.        
  27.         Decimal Result;
  28.         unsigned int res_size = this->size + 1;
  29.         for (unsigned int i = 0; i < res_size-1; i++)
  30.         {
  31.             if (this->_array[i] + other._array[i] >= 10)
  32.             {
  33.                 Result._array[i] = (this->_array[i] + other._array[i]) % 10;
  34.                 Result._array[i + 1] += 1;
  35.             }
  36.             else
  37.             {
  38.                 Result._array[i] = (this->_array[i] + other._array[i]);
  39.             }
  40.         }
  41.         return Result;
  42.     }
  43.  
  44. public:
  45.     ~Decimal();
  46. };
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