mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
38 lines
812 B
C++
38 lines
812 B
C++
|
#include <stdio.h>
|
||
|
#include <iostream>
|
||
|
#include <string>
|
||
|
#include <string.h>
|
||
|
#include <algorithm>
|
||
|
#include <math.h>
|
||
|
using namespace std;
|
||
|
double s[25],temp[25];
|
||
|
int main()
|
||
|
{
|
||
|
int n;
|
||
|
while(scanf("%d", &n) && n)
|
||
|
{
|
||
|
for(int i = 1; i <= n; ++i)
|
||
|
{
|
||
|
scanf("%lf", &s[i]);
|
||
|
temp[i] = s[i];
|
||
|
}
|
||
|
sort(temp + 1, temp + n + 1);
|
||
|
double sum = 0;
|
||
|
for(int i = 2; i < n; ++i)
|
||
|
sum += temp[i];
|
||
|
sum /= (n - 2);
|
||
|
double min = 10000000;
|
||
|
int ans;
|
||
|
for(int i = 1; i <= n; ++i)
|
||
|
{
|
||
|
if(fabs(s[i] - sum) < min)
|
||
|
{
|
||
|
min = fabs(s[i] - sum);
|
||
|
ans = i;
|
||
|
}
|
||
|
}
|
||
|
printf("%d\n", ans);
|
||
|
}
|
||
|
return 0;
|
||
|
}
|