Example: Green song scoring procedure. Remove the two highest points, remove the two minimum points, and then calculate the average score. The main learning array and bubble sort, under what circumstances to define an array

Source: Internet
Author: User

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

int Renshu = Convert.ToInt32 (Console.ReadLine ());//number of people substituting

int[] Fenshu = new int[renshu];//defines an array of fractions of the length of the population

if (Renshu >= 5)//Remove a maximum score, remove two minimum points, so at least five people

{

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

{

Console.Write ("Please enter the" + (i + 1) + "judges hit the Score:");

Fenshu[i] = Convert.ToInt32 (Console.ReadLine ());

}

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

{

for (int j = i; J < Renshu-1; J + +)//bubble sort, sorted from highest to lowest score

{

if (Fenshu[i] < Fenshu[j + 1])

{

int zhong = 0;

Zhong = fenshu[i];

Fenshu[i] = fenshu[j + 1];

Fenshu[j + 1] = Zhong;

}

}

}

int he = 0;//calculates the total score, with an initial value of 0

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

{

He + = fenshu[i];//Cycle calculation score

}

Double PJF = 0;//Initial value is 0

PJF = (he-fenshu[0]-fenshu[1]-fenshu[renshu-1]-fenshu[renshu-2])/(RENSHU-4); Calculates the average score. Fenshu[renshu-1], fenshu[renshu-2]), these two represent the lowest score, and the second lowest score of the penultimate, may not be well understood. In the previous bubble cycle, the scores have been ranked well. Renshu represents the length of the underlying, minus one is the last position of the subscript, which is the lowest

Console.WriteLine ("Remove two highest points" + fenshu[0] + "," + fenshu[1] + ", remove two minimum points" + fenshu[renshu-1] + "," + fenshu[renshu-2 "+ "The final score for the contestant is" + PJF);

}

Else

{

Console.WriteLine ("Please enter a minimum of five persons");

}

Console.ReadLine ();

Example: Green song scoring procedure. Remove the two highest points, remove the two minimum points, and then calculate the average score. The main learning array and bubble sort, under what circumstances to define an array

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.