首页 > 代码库 > 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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。