zoukankan      html  css  js  c++  java
  • 选秀节目打分

    选秀节目打分,分为专家评委和大众评委,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)

     1 #include<stdio.h>
     2 int cal_score(int score[], int judge_type[], int n)
     3 {
     4     int sum1,sum2,i,a;
     5     sum1 = 0;
     6     sum2 = 0;
     7     a = 0;
     8     for (i=0; i < n; i++)
     9     {
    10         if (judge_type[i] == 1)
    11         {
    12             a++;
    13             sum1 += score[i];
    14         }
    15         else
    16         {
    17             sum2 += score[i];
    18         }
    19     }
    20     if (n-a == 0)
    21         return sum1/n;
    22     else if (a == 0)
    23         return sum2/n;
    24     else return (sum1/a) * 0.6 + (sum2/(n-a)) * 0.4;
    25 }
    26 int main()
    27 {
    28     int n,score[100],judge_type[100];
    29     scanf("%d",&n);
    30     for (int i=0; i < n; i++)
    31         scanf("%d%d",&score[i],&judge_type[i]);
    32     printf("%d
    ",cal_score(score,judge_type,n));
    33     return 0;
    34 }

  • 相关阅读:
    NOIP2010提高组乌龟棋 -SilverN
    NOIP2009 提高组T3 机器翻译 解题报告-S.B.S
    controller向layout传值
    解决Yii2中刷新网页时验证码不刷新的问题
    关联表 重命名
    定义action的允许访问方式
    js 拷贝clone
    是否包含指定字符串
    indexOf()定义和用法
    直接借鉴的 ids拼接
  • 原文地址:https://www.cnblogs.com/george-cw/p/3936107.html
Copyright © 2011-2022 走看看