The best referee of the small Q series

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.