zoukankan      html  css  js  c++  java
  • 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
    ", 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;
    }
    

      

  • 相关阅读:
    ionic框架
    第3课
    第7课
    第6课
    第5课
    第4课
    第3课
    第2课
    第2课
    第1课
  • 原文地址:https://www.cnblogs.com/mrethan/p/4152110.html
Copyright © 2011-2022 走看看