#include
int cal_score(int score[], int judge_type[], int n)
{
int i, m, pro_sum, pub_sum, totle; //数组下标,大众评委个数,专家评分,大众评分,得分
m = 0;
pro_sum = 0;
pub_sum = 0;
for (i = 0; i < n; ++ i)
{
if (1 == judge_type[i])
{
pro_sum += score[i];
}
else if (2 == judge_type[i])
{
pub_sum += score[i];
++ m;
}
}
if (0 == m)
{
totle = pro_sum / n;
}
else if (m == n)
{
totle = (int)(pub_sum / m * 0.4);
}
else
{
totle = (int)(pro_sum / (n - m) * 0.6 + pub_sum / m * 0.4);
}
return totle;
}
int main()
{
int score[5] = {9, 7, 5, 7, 8};
int judge_type[5] = {2, 2, 1, 1, 1};
printf("得分为:%d\n", cal_score(score, judge_type, 5));
return 0;
}
int cal_score(int score[], int judge_type[], int n)
{
double endscore;
for(int i=0;i
if(judge_type[i]==1)
endscore+=score[i]*0.6;
else
endscore+=score[i]*0.4;
}
return (int) endscore;
}
int cal_score(int score[], int judge_type[], int n)
{
int comon_sum_score = 0;
int comon_num = 0;
int exper_sum_score = 0;
int exper_num = 0;
float sum_score = 0.0;
for(int i = 0; i < n; i++)
{
if(1 == judge_type[i])
{
comon_sum_score += score[i];
comon_num++;
}
else if(2 == judge_type[i])
{
exper_sum_score += score[i];
exper_num++;
}
else
{
printf("\r The type is ERROR\n");
}
}
sum_score = 0.4*(comon_sum_score/comon_num) + 0.6*(exper_sum_score/exper_num);
return (int )sum_score
}