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 }

  • 相关阅读:
    IP的幻觉
    糟糕的一天
    windows下批量生成文件
    基于Bandersnatch搭建本地pypi源
    vmware vsphere 无法启动故障;
    关于Centos7客户端代理配置
    怎样在交换机判断是否出现环路了呢?
    小小的网络故障
    express for LINUX
    ESXI 7.0 ovf 导出;
  • 原文地址:https://www.cnblogs.com/george-cw/p/3936107.html
Copyright © 2011-2022 走看看