daily pastebin goal
71%
SHARE
TWEET

Untitled

axeefectushka Jan 22nd, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class first
  5. {
  6. protected:
  7.     int *mas;
  8.     int size;
  9. public:
  10.     first()
  11.     {
  12.         cout << "Size: "; cin >> size; cout << endl;
  13.         mas = new int[size];
  14.         cout << "Array : ";
  15.         for (int i = 0; i < size; i++)
  16.         {
  17.             cin >> mas[i]; cout << " ";
  18.         }
  19.         cout << endl;
  20.     }
  21.     void min()
  22.     {
  23.         int min = mas[0];
  24.         for (int i = 1; i < size; i++)
  25.         {
  26.             if (this->mas[i] < min)
  27.             {
  28.                 min = this->mas[i];
  29.             }
  30.         }
  31.         cout << "MIN = " << min << endl;
  32.     }
  33.     ~first() {}
  34. };
  35.  
  36. class second :public first
  37. {
  38. public:
  39.     void max()
  40.     {
  41.         int max = mas[0];
  42.         for (int i = 1; i < size; i++)
  43.         {
  44.             if (this->mas[i] > max)
  45.             {
  46.                 max = this->mas[i];
  47.             }
  48.         }
  49.         cout << "MAX = " << max << endl;
  50.     }
  51. };
  52.  
  53.  
  54. int main()
  55. {
  56.     second b;
  57.     b.max();
  58.     b.min();
  59.     return 0;
  60. }
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
 
Top