After some scandals in the Winter Olympics, figure skating, nine judges (instead
ID: 3563630 • Letter: A
Question
After some scandals in the Winter Olympics, figure skating, nine judges (instead of 8 as in the past) will give a real score between 0 and 6.The highest score and the lowest score are eliminated (once) and the average of 7 ratings stored are displayed.
Example: A skater has received the following 9 ratings:
5.8 5.6 5.6 5.9 5.7 5.9 5.4 5.8 5.7
The lowest rating is 5.4
The highest rating is 5.9 (2 times)
We eliminate these two ratings to obtain the rating of the skater :
5.8 + 5.6 + 5.6 + 5.7 + 5.9 + 5.8 + 5.7
---------------------------------------------
7
This calculation is equavilent to :
( 5.8 + 5.6 + 5.6 + 5.9 + 5.7 + 5.9 + 5.4 + 5.8 + 5.7 ) - ( 5.4 + 5.9)
------------------------------------------------------------------------------
7
which will be presented in the algorithm below.
sumScores <--- 0
scoreHigh <--- FLT_MIN (the smallest real)
scoreLow <--- FLT_MAX (the biggest real)
For numberJudge varies from 1 to 9 Do
Beginning
Ask the user to enter the number of the judge noted "numberJudge"
Read score
sumScores <--- sumScores + score
IF score > scoreHigh Then scoreHigh <--- score
IF score < scoreLow Then scoreLow <--- score
End
scoreOfSkater <--- (sumScores - scoreHigh - scoreLow) / 7
Display at the screen scoreOfSkater
Write a program in interactive mode which allows to:
- Seize 9 ratings typed on the keyboard by the user (you are not required to validate
if the note typed is between 5.0 and 6.0)
- Calculate and display the skater
Explanation / Answer
#include<stdio.h>
int main()
{
int i,z=1,nos=0,tos=0;
float score,a[9],max=0,min=10,sum=0,bfs=0,lfs=10,avg=0;
do
{
nos++;
printf(" enter the 9 ratings of present skater: ");
for(i=0;i<9;i++)
{
scanf("%f",&a[i]);
}
for(i=0;i<9;i++)
{
sum=sum+a[i];
if(max<=a[i])
max=a[i];
if(min>=a[i])
min=a[i];
}
score=(sum-max-min)/7;
printf(" score of present skater= %f",score);
if(score>=5.5)
tos++;
if(bfs<=score)
bfs=score;
if(lfs>=score)
lfs=score;
avg=avg+score;
sum=0;
score=0;
max=0;
min=10;
printf(" Enter 1 to type next skater ratings,0 to stop");
scanf("%d",&z);
}
while(z>0);
avg=avg/nos;
printf(" Total number of treated skaters=%d Total number of skaters whose final score is greater than or equal to 5.5= %d Average final scores= %f Best final score= %f Lowest final score= %f ",nos,tos,avg,bfs,lfs);
return 0;
}
NOTE:
The above code gives you the following:
a) the total number of treated skaters.
b) the total number of skaters whose final score> = 5.5 We determine and display:
c) the average final grade;
d) the best final score;
e) the lowest final grade.