Advertisement
Guest User

for you

a guest
Dec 9th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2. // óäàëèòü èç ìàññèâà âñå ìàêñèìàëüíûå ýëåìåíòû
  3. using namespace std;
  4. int main (){
  5.     int n, max = INT_MIN;
  6.     cout << "Enter n: ";
  7.     cin >> n;
  8.     int* a = new int [n];
  9.     for (int i = 0; i < n; i++){
  10.         cin >> a[i];
  11.     }
  12.     for (int i = 0; i <= n; i++) {
  13.         if (a[i] >= max){
  14.             max = a[i];
  15.         }
  16.     }
  17.     for (int i = 0; i < n; i++){
  18.         if (a[i] == max){
  19.             a[i] = a[i+1];
  20.             n--;
  21.         }
  22.     }
  23.     for (int i = 0; i < n; i++) cout << a[i] << '\t';
  24.     cout << endl;
  25.     system ("pause");
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement