Advertisement
AndreyKlipikov

[Olegu] Prog. Lab6. N26

Dec 25th, 2013
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <math.h>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.         int n, a[10010];
  9.         cout << "Vvedite kolichestvo elementov: " << endl;
  10.         cin >> n;
  11.         cout << "Vvedite elementi massiva:"  << endl;
  12.         for(int i = 0; i < n; i++)
  13.                 cin >> a[i];
  14.  
  15.         int max = 0, x = 0;
  16.         for(int j = 1; j < n - 1; j++)
  17.                 if (a[j] > a[max])
  18.                     max = j;
  19.         x = a[max - 1];
  20.          cout << "x:"  << x << endl;
  21.         for(int i = 0; i < n; i++) {
  22.             if (a[i] < x) {
  23.                 for(int j = i + 1; j < n; j++)
  24.                     a[j - 1] = a[j];
  25.                 --n;
  26.                 --i;
  27.             }
  28.         }
  29.  
  30.         cout << "Obnovlenniy massiv:"  << endl;
  31.         for(int i = 0; i < n; i++)
  32.             cout <<  a[i] << " ";
  33.  
  34.         return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement