#include <iostream>

int main() {
    int n;
    int avg = 0;
    std::cin >> n;
    int *samples = new int [n];
    int num = n;
        if (n < 1) {
        return 0;
    }
    for(int i = 0; i < n; i++) {
        std::cin >> samples[n];
        avg += samples[n];
        
    }
    std::cout << (avg/num);

    delete[] samples;

    // Write your dynamic buffer allocation code here

    return 0;
}

Solving Approach

 

 

 

 

 

Upvote
Downvote
Loading...

Input

5 10 20 30 40 50

Expected Output

30