Sorting method: Remove the highest minimum to find the average function of the division

Source: Internet
Author: User

Method 1

Namespacefunction Array Sorting takes out the maximum minimum and average value {classProgram {Static voidMain (string[] args) { int[] b=New int[]{9,1,5,3,7}; intMax =0;//set two variables to receive minimum and minimum values. intMin =0; intAve =0;//Set Variable to receive the average. int[]a=NewProgram (). Array (b, outMax outMin outAve); for(inti =0; i < b.length; i++) {Console.WriteLine (b[i]); } Console.WriteLine ("Maximum Value"+max); Console.WriteLine ("Minimum Value"+min); Console.WriteLine ("Average"+Ave); Console.ReadLine (); } Public int[] Array (int[]a, out intX out intY out intAve//jump out of the X, Y and Ave three variables and return the INT[]A variable. { inttemp =0; for(inti =1; I <= a.length; i++) { for(intj =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];//Maximum Valuey=a[a.length-1];//Minimum Value intsum =0; for(inti =0; i < a.length; i++) {sum= Sum +A[i]; } Ave= SUM/(a.length); returnA; } }}

Method 2
namespaceconsoleapplication10{classProgram { Public Double[] Paixu (Double[] a) {Doubletemp;  for(inti =0; i < a.length; i++)//number of bit loops quick sort            {                 for(intj = i; J < A.length-1; J + +)//number of digits compared to the following                {                    if(A[i] < A[j +1]) {temp=A[i]; A[i]= A[j +1]; A[j+1] =temp; }                }            }            returnA; }        Static voidMain (string[] args) {Console.backgroundcolor=Consolecolor.white;            Console.clear (); Double[] A =New Double[5]; Doublesum =0;  for(inti =0; i < a.length; i++) {A[i]=Convert.ToInt32 (Console.ReadLine ()); Sum= Sum +A[i]; Console.foregroundcolor=consolecolor.red; Console.WriteLine ("Section"+ (i +1) +"A judge's score is"+A[i]); } Console.foregroundcolor=consolecolor.red; Console.WriteLine ("Total score is"+sum); Double[] B =NewProgram (). Paixu (a);  for(inti =0; I <a.Length; i++) {Console.WriteLine (a[i]); } Console.foregroundcolor=consolecolor.red; Console.WriteLine ("Highest score"+ a[0]); Console.WriteLine ("Minimum score"+ a[4]); DoublePJ = (sum-a[0]-a[4])/(a.length-2); Console.WriteLine ("The average final score after removing a maximum score and a minimum score is"+PJ);        Console.ReadLine (); }    }}

Sorting method: Remove the highest minimum to find the average function of the division

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.