#include <iostream>
#include <vector>
using namespace std;
void solve(){
int n;
cin >> n;
vector<double> a(n);
double minValue, maxValue;
for(int i = 0; i < n; i++){
cin >> a[i];
if(i == 0){
minValue = a[i];
maxValue = a[i];
}
else{
minValue = min(minValue, a[i]);
maxValue = max(maxValue, a[i]);
cout << (minValue + maxValue) / 2;
int main(){
solve();
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
#include <iostream>
#include <vector>
using namespace std;
void solve(){
int n;
cin >> n;
vector<double> a(n);
double minValue, maxValue;
for(int i = 0; i < n; i++){
cin >> a[i];
if(i == 0){
minValue = a[i];
maxValue = a[i];
}
else{
minValue = min(minValue, a[i]);
maxValue = max(maxValue, a[i]);
}
}
cout << (minValue + maxValue) / 2;
}
int main(){
solve();
}