This topic needs to be aware of some data conditions
In particular, some input data conditions
#include <algorithm>#include<stdio.h>#include<math.h>using namespacestd;intMain () {intN,m,i; floatb[ +],a[ +]; Doubles,k; M= +; while(SCANF ("%d",&N)) {if(n==0|| n<5)//on this condition special pit thought for a long time did not expect to pay attention to this condition. Break; S=0; for(i=0; i<n;i++) {scanf ("%f",&B[i]);
A[i]=b[i];//first put the number and serial number, in order to later not disorderly serial number. } sort (B,b+n);//Sort. for(i=1; i<n-1; i++) {s=b[i]+s; }s=s/(n2)///minus the maximum and minimum sums to find the average for(i=0; i<n;i++) {B[i]=fabs (b[i]-s); } k=b[1]; for(i=1; i<n-1; i++) { if(b[i]<k) {k=b[i];//The absolute value of the minimum by subtracting the average. } } for(i=0; i<n;i++) {A[i]=fabs (a[i]-s), minus the average by the original sequence number ,if(a[i]==k) is equal to the smallest post-output sequence number compared to the smallest. {printf ("%d\n", i+1); Break; } } }}
The best referee of the small Q series