- /*
-
-
-
-
-
-
-
- */
- #include <stdio.h>
int cal_score(int score[], int juge_type[], int n) { int expert_s = 0; int nomoal_s = 0; int i,expert_num = 0; int total = 0; for(i = 0;i < n;i++) { if(juge_type[i] == 1) { expert_s += score[i]; expert_num++; } else if(juge_type[i] == 2) nomoal_s += score[i]; } if(expert_num == n) total = (float)expert_s / expert_num; else total = ((float)expert_s / expert_num) * 0.6 + ((float)nomoal_s / (n - expert_num)) * 0.4; return total; } int main() { int n = 10; int score[10] = {70,75,90,90,85,95,87,90,99,92}; int judge_type[10] = {1,1,2,1,1,2,2,2,1,2}; printf("Final score is %d\n",cal_score(score,judge_type,n)); return 0; }
|
|