1、选秀节目打分,分为专家评委和大众评委, score[] 数组里面存储每个评委打
的分数,judge_type[] 里存储与 score[] 数组对应的评委类别, judge_type[i] ==
1,表示专家评委, judge_type[i] == 2,表示大众评委, n 表示评委总数。打分
规则如下:专家评委和大众评委的分数先分别取一个平均分(平均分取整),然
后,总分 = 专家评委平均分 * 0.6 + 大众评委 * 0.4,总分取整。如果没有大
众评委,则 总分 = 专家评委平均分,总分取整。函数最终返回选手得分。
函数接口 int cal_score(int score[], int judge_type[], int n)
#include<iostream>
int cal_score(int score[], int judge_type[], int n)
{
int i =0;
int sum1=0, sum2=0;
int count1=0,count2=0;
int zhongfen=0;
for(i =0; i<n; i++)
{
if(1==judge_type[i])
{
sum1+=score[i];
count1++;
}
else //if(2==judge_type[i])
{
sum2+=score[i];
count2++;}
}
if(count2==0)
{
- 1
- 2
前往页