Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1291846
  • 博文数量: 168
  • 博客积分: 2124
  • 博客等级: 大尉
  • 技术积分: 2590
  • 用 户 组: 普通用户
  • 注册时间: 2011-09-16 23:51
文章分类

全部博文(168)

文章存档

2014年(6)

2013年(74)

2012年(71)

2011年(17)

分类: IT职场

2013-08-07 16:34:46


点击(此处)折叠或打开

  1. /**************************************************************
  2. 1、选秀节目打分,分为专家评委和大众评委,
  3. score[] 数组里面存储每个评委打的分数,
  4. judge_type[] 里存储与 score[] 数组对应的评委类别,
  5. judge_type == 1,表示专家评委,judge_type == 2,表示大众评委,n表示评委总数。
  6. 打分规则如下:专家评委和大众评委的分数先分别取一个平均分(平均分取整),
  7. 然后,总分 = 专家评委平均分 * 0.6 + 大众评委 * 0.4,总分取整。如果没有大众评委,
  8. 则 总分 = 专家评委平均分,总分取整。函数最终返回选手得分。
  9. 函数接口 int cal_score(int score[], int judge_type[], int n)
  10. **************************************************************/

  11. /*
  12. 函数接口 int cal_score(int score[], int judge_type[], int n)
  13. */

  14. #include<stdio.h>
  15. /*****************************************************
  16. 编程思路:
  17. .对judge_type数组进行历遍,
  18.         对大众评审和普通评审计数,
  19.         并计算出专家评审和大众评审的总分
  20. .如果没有打中评审,返回专家平均值
  21. .计算出平均值,并根据所给的表达式返回计算的值
  22. *******************************************************/
  23. int cal_score(int score[], int judge_type[], int n)
  24. {
  25.     int i, pro_c, nor_c, pro_t, nor_t, pro_a, nor_a;
  26.     //pro_c代表大众评审数,nor_c代表专家评审数, pro_a专家平均值,nor_a普通评委平均值,por_t,nor_t专家和普通的总值
  27.     
  28.     pro_c = nor_c = pro_t = nor_t = 0;
  29.     for(i = 0; i < n; i++)
  30.     {
  31.         if(judge_type[i] == 1)
  32.         {
  33.             pro_c++;
  34.             pro_t += score[i];
  35.         }
  36.         if(judge_type[i] == 2)
  37.         {
  38.             nor_c++;
  39.             nor_t += score[i];
  40.         }    
  41.     }        
  42.     //计数
  43.     if(nor_c == 0)
  44.     {
  45.         return (pro_t / n);    
  46.     }    
  47.     
  48.     pro_a = pro_t / pro_c;
  49.     nor_a = nor_t / nor_c;
  50.     
  51.     return pro_a * 0.6 + nor_a *0.4 ;
  52. }

  53. int main(int argc, char **argv)
  54. {
  55.     int n, i, t;
  56.     
  57.     int score[5] = {1, 2, 3, 4, 5};
  58.     int judge[5] = {1, 1, 2, 2, 1};
  59.     
  60.     t = cal_score(score, judge, 5);
  61.     
  62.     printf(" t = %d", t);
  63.     
  64.     while(1);
  65. }

阅读(737) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~