题目描述:https://www.patest.cn/contests/pat-a-practise/1125
#include <iostream>
#include <algorithm>
using namespace std;
#define MAX 10010
int main ()
{
int n,i;
int j;
double num[MAX];
cin>>n;
for( i=0;i<n;++i)
{
scanf("%lf",&num[i]);
}
sort(num,num+n);
for( i=0;i<n-1;++i )
{
double a = num[i],b = num[i+1];
num[i+1] = a/2 + b/2;
//cout<<a/2 + b/2<<endl;
//sort(num+i+1,num+n); 不用每次都排序,二分之一之后数变得更小了,直接插入就行了
//
/**
for(j=i+1;j<n;++j)
{
if( j==n-1 )
cout<<num[j]<<"***"<<endl;
else
cout<<num[j]<<" ";
}
*/
}
printf("%d\n",(int)num[n-1]);
return 0;
}