Quick actions

cmd+k|ctrl+k

Navigation

Languages

lab6_217

Snippet info

Language

Cpp

Visibility

public

Author

maloy-

Created

2018-12-11T19:19:40Z

Updated

2018-12-11T19:19:40Z

#include <iostream>
using namespace std;

int main() {
    const int n = 20 ; 
    int a[n] , b[n] ;
    for (size_t i = 0 ; i < n ; i++){
        a[i] = rand() % 100 ; 
        cout << a[i] << " - " ;
        b[i] = a[i] ; 
    }
    
    int max = -1000 , min = 1000;
    
    
    for (size_t i = 0 ; i < n ; i++){
        if (a[i] > max ){
            max = a[i];
        }
        if (a[i] < min ){
            min = a[i];
        }
    }
    
    cout << endl << "MAX = " << max << endl ; 
    cout << "MIN = " << min << endl ; 
    int x=0 ;
    for (size_t i = 0 ; i < n ; i++){
        if (a[i] == max){
            x = i+1 ; 
            for (size_t j = i-1 ; j < n ; j++){
                b[j] = a[x];
                x++;
                
            }
        }
        if (a[i] == min){
            x = i+1 ;
            for (size_t j = i ; j < n; j++){
                b[j] = a[x];
                x++;
            }
        }
        
        
    }
    
    for (size_t i = 0 ; i < n-2 ; i++){
        cout << b[i] << " - " ;
    }
    
    return 0;
}
INFO