[HDU] [2014] Young Singer Grand Prix_Judges' Scoring

Problem Description

Loading...

Problem Analysis

Why do I feel like looking at this kind of problem now — one that felt so complicated back then
it’s just…
Did it really need to be written like this?
This much trouble?

cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include<stdio.h>
int main() {
    int n,k,i,t;
    double re;
    int x[120];
    while(scanf("%d",&n)!=EOF) {
        for(i=0; i<n; i++)
            scanf("%d",&x[i]);
        for(k=0; k<n; k++)
            for(i=0; i<n-1-k; i++) {
                if(x[i]>x[i+1]) {
                    t=x[i];
                    x[i]=x[i+1];
                    x[i+1]=t;
                }
            }
        for(i=1,re=0; i<n-1; i++)
            re=re+x[i];
        printf("%.2lf\n",re/(n-2));
    }
    return 0;
}

Loading...