• 排序方法:去掉最高最低分求平均分 函数


    法1

    namespace
    函数数组排序带出最大最小值及平均值 { class Program { static void Main(string[] args) { int[] b=new int[]{9,1,5,3,7}; int max = 0; //设置两个变量用来接收最低值与最小值。 int min = 0; int ave = 0; //设变一个变量来接收平均值。 int[]a= new Program().Array(b,out max,out min,out ave); for (int i = 0; i < b.Length; i++) { Console.WriteLine( b[i]); } Console.WriteLine("最大值"+max); Console.WriteLine("最小值"+min); Console.WriteLine("平均值"+ave); Console.ReadLine(); } public int[] Array(int[]a,out int x,out int y,out int ave) //跳出x,y和ave三个变量,返回int[]a变量。 { int temp = 0; for (int i = 1; i <= a.Length; i++) { for (int j = 1; j <= a.Length-i; j++) { if(a[j-1]<a[j]) { temp = a[j - 1]; a[j - 1] = a[j]; a[j] = temp; } } } x = a[0]; //最大值 y=a[a.Length-1]; //最小值 int sum = 0; for (int i = 0; i < a.Length; i++) { sum = sum + a[i]; } ave = sum / (a.Length); return a; } } }

    法2
    namespace ConsoleApplication10
    {
        class Program
        {    
            public double[] paixu(double[] a)
            {
                double temp;
                for (int i = 0; i < a.Length; i++)//位数循环 快速排序
                {
                    for (int j = i; j < a.Length - 1; j++)//位数与后面的比较
                    {
                        if (a[i] < a[j + 1])
                        {
                            temp = a[i];
                            a[i] = a[j + 1];
                            a[j + 1] = temp;
                        }
                    }
                }
                return a;
            }
            static void Main(string[] args)
            {
                Console.BackgroundColor = ConsoleColor.White;
                Console.Clear();
                double[] a = new double[5];
                double sum = 0;
                for (int i = 0; i < a.Length; i++)
                {
                    a[i] = Convert.ToInt32(Console.ReadLine());
                    sum = sum + a[i];
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("" + (i + 1) + "个评委的分数为" + a[i]);
                }
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("总分为"+sum);
    
                double[] b = new Program().paixu(a);
                for (int i = 0; i <a.Length; i++)
                {
                    Console.WriteLine(a[i]);
                }
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("最高分" + a[0]);
                Console.WriteLine("最低分" + a[4]);
                double pj = (sum - a[0] - a[4])/(a.Length-2);
                Console.WriteLine("去掉一个最高分和最低分之后的平均最后得分为" + pj);  
                Console.ReadLine();
            }
        }
    }
    
    
    
     
    二百个不间断的重复,只是让我看到了人的命运无法改变这一事实而已。
  • 相关阅读:
    Map Rectifier
    倡议“开源GIS团队”成员集思广言
    动力火车终于明白
    搜索操作被google拒绝
    请教ArcGIS server 9.2做的题目的部署问题
    总结基于ArcGIS Server 9.2 Dot Net ADF的WebGIS项目部署问题
    读:『博客家园』 [博客人生]结婚是因为无路可逃
    [Gdaldev] gdalwarp/gcps and ERROR 1: Failed to compute polynomial equations of desired order
    [Gdaldev]用GCPs纠正影像的完整代码(多项式纠正)
    转:将 Oracle Spatial 与 Google Earth 集成
  • 原文地址:https://www.cnblogs.com/dlexia/p/4439436.html
Copyright © 2020-2023  润新知