Question: During the singer Grand Prix, 10 judges scored the contestants and scored 1 ~ 100 points. The final score is: remove the highest score and the most

Source: Internet
Author: User

[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:

 

 


Related Article

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.