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.
========================================================== ======================================
*/