Basic C language algorithms-remove the highest score, remove the lowest score, and calculate the average value

Source: Internet
Author: User

Basic C language algorithms-remove the highest score, remove the lowest score, and calculate the average value
//
/*
========================================================== ======================================
Question: This method is usually used to calculate a contestant's score during the competition. Remove a highest score and
Lowest score, calculate the average score! Program this calculation method.
========================================================== ======================================
*/
# Include
Main ()
{
Float a [10], max, min, sum = 0.0, aver;
Int I;
Printf (input score :);
For (I = 0; I <10; I ++)
{
Printf (score % 2d:, I + 1 );
Scanf (% f, & a [I]);
If (a [I] <0) | (a [I]> 10 ))
{
Printf (incorrect Score Input !, Make sure that the score is 0-10! ______________________________);
I =-1;
}
}
Max = a [0]; min = a [0];
For (I = 0; I <10; I ++)
{
If (max = a [I];
If (min> a [I])
Min = a [I];
Sum = sum + a [I];
}
Aver = (sum-max-min)/8;
Printf (remove the highest score: %. 1f, max );
Printf (remove a partition: %. 1f, min );
Printf (average score: %. 2f, aver );
}
/*
========================================================== ======================================
Rating: define the number of judges (10), input the score (Series a []), calculate the maximum and minimum values, and sum
Sum, calculates sum-highest score-lowest score, and calculates the average value.
========================================================== ======================================
*/

Related Keywords:
Related Article

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.