Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #include <iostream>
  2. #include <clocale>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.   setlocale(LC_ALL, "Russian");
  9.   int n, m, M, im, iM;
  10.   cout << "Введите количество элементов (разных): ";
  11.   cin >> n;
  12.  
  13.   int *arr1 = new int [n];
  14.  
  15.   for ( int i = 0; i < n; i++)
  16.   {
  17.     cout << "\nВведите число: ";
  18.     cin >> arr1[i];
  19.   }
  20.  
  21.   cout << "\nМы имеем массив:\n";
  22.   im = 0;
  23.   iM = 0;
  24.   m = arr1[im];
  25.   M = arr1[iM];
  26.   for (int i = 0; i < n; i++)
  27.   {
  28.     cout << arr1[i] << "\t";
  29.  
  30.     if (arr1[i] >= arr1[iM])
  31.     {
  32.       M = arr1[i];
  33.       iM = i;
  34.     }
  35.  
  36.     else if (arr1[i] <= arr1[im])
  37.     {
  38.       m = arr1[i];
  39.       im = i;
  40.     }
  41.   }
  42.  
  43.   cout << "\nm=" << arr1[im];
  44.   cout << "\nM=" << arr1[iM];
  45.   cout << "\n";
  46.    for(int i = m + 1; i <= M - 1; i++) {
  47.     int j = 0;
  48.     while(j < n && arr1[j] != i){
  49.       j++;
  50.     }
  51.     if (j == n)
  52.       cout << i;
  53.   //    cout << i << "\t";}
  54.    }
  55.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement