Quick actions

cmd+k|ctrl+k

Navigation

Languages

lab6_111

Snippet info

Language

Cpp

Visibility

public

Author

maloy-

Created

2018-12-11T17:02:06Z

Updated

2018-12-11T17:03:11Z

#include <iostream>
using namespace std;

int main() {
    const int n = 20 ; 
    int a[n] , b[n], k , j = 0  , sum =0 ;
    cout << "Ведите место на которое нужно вставить элемент..." << endl ;
    cin >> k  ;
    for (size_t i = 0 ; i < n ; i++){
        a[i] = rand () % 10 ; 
        cout << a[i] << " - " ; 
        sum += a[i] ; 
        j++;
        b[i] = a[i];
    }
    double x ; 
    x = sum / j ; 
    int x1 = 0 ; 
     cout <<endl <<  "Среднее арифм. = " << x << endl ; 
    for (size_t i = 0 ; i < n ; i++){
        if ( i+1 == k ) {
            a[i] = x ;
            b[i+1] = x;
            x1 = i ; 
            for (size_t q = k ; q < n+1 ; q++){
               b[q] = a[x1];
               x1++;
            }
        }
    }
    
    
    for (size_t i = 0 ; i < n+1 ; i++){
        cout << b[i] << " - " ; 
    }
    
    
    return 0;
}
INFO