Title: Talent Show Rating
Talent show score, divided into expert judges and the public judges, score[] array to store each judge scored points, judge_type[] score[] array corresponding to the jury category, judge_type[i] = = 1, representing the expert judges; Judge_type[i] = = 2, representing the public jury, n represents the total number of judges.
The scoring rules are as follows:
the scores of the expert judges and the public judges were first divided by an average (average sub-rounding), Then, the total score = The expert Judges average divided *0.6 + the general jury *0.4, total score rounding.
If there is no mass jury, then the total score = Expert Judges, the total score rounding. The function eventually returns the player's score.
function interface int Cal_score (int score[], int judge_type[], int n)
#include <iostream> using namespace std; int cal_score (int score[], int judge_type[], int n) { int result = 0; int sum1 = 0.0; int sum2 = 0.0; int ans = 0;//expert jury for (int i = 0;i < n;i++) { if (judge_type[i] = = 1) { ans++; Sum1 + = Score[i]; } else if (judge_type[i] = = 2) sum2 + = Score[i]; } if (ans = = N) result = Sum1/ans; result = 0.6* (Sum1/ans) + 0.4* (sum2/(N-ans)); return result; } int main () { int n = ten; int score[10] = {80,85,90,80,75,95,80,90,95,92}; int judge_type[10] = {1,1,1,1,1,1,2,2,2,2}; cout << Cal_score (score,judge_type,n) << Endl; return 0; }
Huawei Machine test-talent show rating