首页 > 代码库 > HDU 2014

HDU 2014

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>typedef float ElementType;void Select_Sort(ElementType n[], int num);void Swap(ElementType *a, ElementType *b);int main(){	int num;	float sum;	float score[100];	float result;	while (scanf("%d", &num) != EOF){		sum = 0;		for (int i = 0; i < num; i++){			scanf("%f", &score[i]);		}		Select_Sort(score, num);		for (int i = 1; i < num - 1; i++){			sum += score[i];		}		result = (float)(sum / (num - 2.0));		printf("%.2f\n", result);	}}//排序void Select_Sort(ElementType n[], int num){	for (int i = 0; i < num; i++){		for (int j = i; j < num; j++){			if (n[i] > n[j])				Swap(&n[i], &n[j]);		}	}}void Swap(ElementType *a, ElementType *b){	ElementType temp;	temp = *a;	*a = *b;	*b = temp;}

  

HDU 2014