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 jcnt1=0; int jcnt2=0; int sum1=0; int sum2=0; int result; for (int i=0;i<n;++i) { if (judge_type[i]==1) jcnt1++,sum1+=score[i]; if (judge_type[i]==2) jcnt2++,sum2+=score[i]; } if (jcnt2==0) { result=sum1/jcnt1; } else { result=sum1*1.0/jcnt1*0.6+sum2*1.0/jcnt2*0.4; } return result;} int main (int argc, char *argv[]) { 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