In a match, there are 6 referees giving their scores. In computing the final score, the 1 highest score and the 1 lowest score must be removed before averaging the remaining 4 scores. The average score is just the final score. Please compute the final score for a player based on these refereesĄŻ scores.

Solution:

A | B | C | D | |

1 | [9.8,9.4,9.8,8.9,9.2,9.4] | |||

2 | =func(A4,A1) | |||

3 | ||||

4 | func | =A4.count() | ||

5 | if B4!=6 | return 0 | ||

6 | =round((A4.sum()-A4.max()-A4.min())/(6-2),3) | return B6 |

In A2, the resulting player score is as follows:

Using subprogram to compute is similar to the model of direct looping and executing. However, the subprogram is easier for code maintenance because the subprogram can be modularized to implement the computation function.