标签:
Time Limit:200MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Description
Input
Output
Sample Input
Sample Output
#include <iostream> #include <stdio.h> #include <algorithm> using namespace std; const int maxd=20; double a[maxd],b[maxd],c[maxd],d[maxd]; double cmp(double a,double b) { return a<b; } int main() { int n,tab; double sum,num; double f1,f2; while (scanf("%d",&n),n) { tab=0; sum=0;num=0;f1=0;f2=0; for (int i=0;i<n;i++) { scanf("%lf",&a[i]); b[i]=a[i]; } sort(a,a+n,cmp); f1=a[0];f2=a[n-1]; a[0]=0;a[n-1]=0; for (int i=0;i<n;i++) sum+=a[i]; num=sum/(n-2); a[0]=f1;a[n-1]=f2; for(int i=0;i<n;i++) { c[i]=(a[i]-num)*(a[i]-num); d[i]=(b[i]-num)*(b[i]-num); } sort(c,c+n,cmp); for (int i=0;i<n;i++) if (c[0]==d[i]) {tab=i;break;} printf("%d\n",tab+1); } return 0; }
标签:
原文地址:http://www.cnblogs.com/gdvxfgv/p/5696275.html