[Plain]
/* Start the comments in the program header (to avoid any problems encountered during the submission of blog posts, the slash used to indicate that the comments have been deleted)
* Copyright and version Declaration of the program
* All rights reserved.
* File name: txt. c
* Author: liuyongshui
* Question: In the singer Grand Prix, 10 judges scored the contestants, with a score of 1 ~ 100 points.
The final score is: remove the average value of one highest score and the other eight scores after one lowest score. Compile a program for implementation.
* Problem source:
* Completion date: January 1, April 22, 2013
* Version No.: V1.0
*/
# Include <stdio. h>
# Define num 10 // ten judges
Void star (void); // print the asterisk
Void sort (float score []); // sort from small to large
Int main ()
{
Int I;
Float sum = 0;
Float average;
Float score [10];
Star (); // print the asterisk
Printf ("Enter the Score \ n for each judge ");
For (I = 0; I <num; I ++)
{
Printf ("% 2d score:", I + 1 );
Scanf ("% f", & score [I]);
}
Sort (score );
For (I = 1; I <num-1; I ++) // calculate the total score after the highest percentile
{
Sum + = score [I];
}
Average = sum/8; // calculate the average score
Printf ("the highest score removed by \ n is % 0.2f \ n", score [num-1]);
Printf ("\ n: % 0.2f \ n", score [0]);
Printf ("\ n after the highest score is removed, your total score is % 0.2f \ n", sum );
Printf ("\ n after the highest score is removed, your average score is: % 0.2f \ n", average );
Printf ("\ n Haha, thank you for your cooperation! \ NGOOD BYE! \ N ");
Star (); // print the asterisk
Return 0;
}
// Sorting Function
Void sort (float score []) // sort from small to large
{
Int I;
Int j;
Float t; // number of exchanges
For (I = 0; I <num; I ++)
{
For (j = I; j <num; j ++)
{
If (score [I]> score [j])
{
T = score [I];
Score [I] = score [j];
Score [j] = t;
}
}
}
}
// Star Function
Void star (void)
{
Int I;
For (I = 0; I <60; I ++)
{
Printf ("*");
}
Printf ("\ n ");
}
/* Start the comments in the program header (to avoid any problems encountered during the submission of blog posts, the slash used to indicate that the comments have been deleted)
* Copyright and version Declaration of the program
* All rights reserved.
* File name: txt. c
* Author: liuyongshui
* Question: In the singer Grand Prix, 10 judges scored the contestants, with a score of 1 ~ 100 points.
The final score is: remove the average value of one highest score and the other eight scores after one lowest score. Compile a program for implementation.
* Problem source:
* Completion date: January 1, April 22, 2013
* Version No.: V1.0
*/
# Include <stdio. h>
# Define num 10 // ten judges
Void star (void); // print the asterisk
Void sort (float score []); // sort from small to large
Int main ()
{
Int I;
Float sum = 0;
Float average;
Float score [10];
Star (); // print the asterisk
Printf ("Enter the Score \ n for each judge ");
For (I = 0; I <num; I ++)
{
Printf ("% 2d score:", I + 1 );
Scanf ("% f", & score [I]);
}
Sort (score );
For (I = 1; I <num-1; I ++) // calculate the total score after the highest percentile
{
Sum + = score [I];
}
Average = sum/8; // calculate the average score
Printf ("the highest score removed by \ n is % 0.2f \ n", score [num-1]);
Printf ("\ n: % 0.2f \ n", score [0]);
Printf ("\ n after the highest score is removed, your total score is % 0.2f \ n", sum );
Printf ("\ n after the highest score is removed, your average score is: % 0.2f \ n", average );
Printf ("\ n Haha, thank you for your cooperation! \ NGOOD BYE! \ N ");
Star (); // print the asterisk
Return 0;
}
// Sorting Function
Void sort (float score []) // sort from small to large
{
Int I;
Int j;
Float t; // number of exchanges
For (I = 0; I <num; I ++)
{
For (j = I; j <num; j ++)
{
If (score [I]> score [j])
{
T = score [I];
Score [I] = score [j];
Score [j] = t;
}
}
}
}
// Star Function
Void star (void)
{
Int I;
For (I = 0; I <60; I ++)
{
Printf ("*");
}
Printf ("\ n ");
} Example: