#include <iostream>
int main() {
int n;
std::cin >> n;
if (n < 1) {
return 0;
}
int* samples = new int[n]; // dynamic sensor buffer
int sum = 0;
for (int i = 0; i < n; i++) {
std::cin >> samples[i];
sum += samples[i];
}
int average = sum / n; // integer division
std::cout << average;
delete[] samples; // free allocated memory
return 0;
}
Explanation & Logic Summary:
new[] allocates memory sized exactly to the required number of samples.delete[] is required to prevent memory leaks in long-running firmware systems.Firmware Relevance & Real-World Context:
Input
5 10 20 30 40 50
Expected Output
30