码迷,mamicode.com
首页 > 其他好文 > 详细

HDU 2014

时间:2014-12-08 22:59:14      阅读:306      评论:0      收藏:0      [点我收藏+]

标签:blog   http   io   ar   for   div   2014   log   ef   

bubuko.com,布布扣

#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

标签:blog   http   io   ar   for   div   2014   log   ef   

原文地址:http://www.cnblogs.com/mrethan/p/4152110.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!