Set sort averaging

Source: Internet
Author: User

static void Main (string[] args)

{

ArrayList al = new ArrayList (); Define a collection

Console.Write ("Please enter the number of people:");

int n = Convert.ToInt32 (Console. ReadLine ());

for (int i = 0; i < n; i++)

{Console.Write ("Please enter" + (i+1) + "Student's score:");

Al. ADD (Convert. ToInt32 (Console.                                  ReadLine ())); Store data type and convert to int type

}

Al.                                                 Sort (); Sort ArrayList or some of his elements ascending here from small to large

Al.                                            Reverse (); Flip entire set flip from big to small

for (int k = 0; k < n; k++)

{

Console.WriteLine (Al[k]);

}//output Order of discharge

Double h = 0;

for (int j = 0; J < N; j + +)

{

H + = convert.todouble (Al[j]); Here the elements are taken out according to the subscript and calculated and

}

Double x = ((H-convert.todouble (al[0])-convert.todouble (al[n-1])/(n-2)); Index starting from 0 so the highest is divided into al[0], the lowest is divided into al[n-1]

Console.WriteLine ("Total Divided into:" +h);

Console.WriteLine ("Remove the highest and lowest average divided into:" +x);

Console.ReadLine ();

}

Set sort averaging

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.