XX届华为校园招聘上机考试题

上传人:l**** 文档编号:128956447 上传时间:2020-04-22 格式:DOC 页数:15 大小:88KB
返回 下载 相关 举报
XX届华为校园招聘上机考试题_第1页
第1页 / 共15页
XX届华为校园招聘上机考试题_第2页
第2页 / 共15页
XX届华为校园招聘上机考试题_第3页
第3页 / 共15页
XX届华为校园招聘上机考试题_第4页
第4页 / 共15页
XX届华为校园招聘上机考试题_第5页
第5页 / 共15页
点击查看更多>>
资源描述

《XX届华为校园招聘上机考试题》由会员分享,可在线阅读,更多相关《XX届华为校园招聘上机考试题(15页珍藏版)》请在金锄头文库上搜索。

1、2012届华为校园招聘上机考试题目(9月6日下午1点场) 分类: 华为准备 2011-09-08 15:10 281人阅读 评论(0) 收藏 举报 在网上看到华为在有的地方已经开始机试了,于是决定自己先编着试试。下面是题目和自己写的代码。1、选秀节目打分,分为专家评委和大众评委,score 数组里面存储每个评委打的分数,judge_type 里存储与 score 数组对应的评委类别,judge_typei = 1,表示专家评委,judge_typei = 2,表示大众评委,n表示评委总数。打分规则如下:专家评委和大众评委的分数先分别取一个平均分(平均分取整),然后,总分 = 专家评委平均分 *

2、0.6 + 大众评委 * 0.4,总分取整。如果没有大众评委,则 总分 = 专家评委平均分,总分取整。函数最终返回选手得分。函数接口 int cal_score(int score, int judge_type, int n)view plaincopy to clipboardprint?1. #include 2. #include 3. #include 4. #include 5. #defineN5 6. 7. intcal_score(intscore,intjudge_type,intn)8. 9. 10. intexpert=0;11. intdazhong=0;12. in

3、tzongfen=0;13. inti;14. intnumber=0;15. 16. for(i=0;iN;i+)17. 18. if(judge_typei=1)19. 20. expert=expert+scorei;21. number+;22. 23. elsedazhong=dazhong+scorei;24. 25. if(number=N)26. 27. zongfen=(int)(expert/N);28. 29. else30. 31. 32. expert=(int)(expert/number);33. dazhong=(int)(dazhong/(N-number);

4、34. zongfen=int(0.6*expert+0.4*dazhong);35. 36. 37. returnzongfen;38. 39. 40. intmain()41. 42. intscoreN;43. intjudge_typeN;44. intnumberlast=0;45. inti;46. printf(pleaseinputthe%dscore:n,N);47. for(i=0;iN;i+)48. scanf(%d,&scorei);49. printf(pleaseinputthelevel(1:expert,2:dazhong)n);50. for(i=0;iN;i

5、+)51. scanf(%d,&judge_typei);52. numberlast=cal_score(score,judge_type,N);53. printf(thelastscoreis%dn,numberlast);54. return0;55. 运行结果分析:please input the 5 score:90 80 87 89 91please input the level(1:expert,2:dazhong)1 2 1 1 1the last score is 85 2、给定一个数组input ,如果数组长度n为奇数,则将数组中最大的元素放到 output 数组最中间

6、的位置,如果数组长度n为偶数,则将数组中最大的元素放到 output 数组中间两个位置偏右的那个位置上,然后再按从大到小的顺序,依次在第一个位置的两边,按照一左一右的顺序,依次存放剩下的数。 例如:input = 3, 6, 1, 9, 7 output = 3, 7, 9, 6, 1; input = 3, 6, 1, 9, 7, 8 output =1, 6, 8, 9, 7, 3view plaincopy to clipboardprint?1. #include 2. #include 3. #include 4. 5. 6. 7. voidsort(intinput,intn,in

7、toutput)8. 9. inti,j;10. intk=1;11. inttemp;12. intmed;13. for(i=0;in;i+)14. for(j=0;jinputj+1)16. temp=inputj;inputj=inputj+1;inputj+1=temp;17. if(n%2!=0)18. 19. for(i=0;in;i+)20. printf(%2d,inputi);21. printf(n);22. med=(n-1)/2;23. outputmed=inputn-1;24. for(i=1;i=med;i+)25. 26. outputmed-i=inputn

8、-1-k;27. outputmed+i=inputn-2-k;28. k=k+2;29. 30. 31. 32. else33. 34. 35. for(i=0;in;i+)36. printf(%2d,inputi);37. printf(n);38. med=n/2;39. outputmed=inputn-1;40. for(i=1;i=med-1;i+)41. 42. outputmed-i=inputn-1-k;43. outputmed+i=inputn-2-k;44. k=k+2;45. 46. output0=input0;47. 48. for(i=0;in;i+)49.

9、printf(%2d,outputi);50. printf(n);51. 52. 53. 54. intmain()55. 56. inta6=3,6,1,9,7,8;57. intb6=0;58. for(inti=0;i6;i+)59. printf(%2d,ai);60. printf(n);61. sort(a,6,b);62. return0;63. 运行结果3 6 1 9 7 81 3 6 7 8 91 6 8 9 7 33、操作系统任务调度问题。操作系统任务分为系统任务和用户任务两种。其中,系统任务的优先级 = 50且 = 255。优先级大于255的为非法任务,应予以剔除。现有

10、一任务队列task,长度为n,task中的元素值表示任务的优先级,数值越小,优先级越高。函数scheduler实现如下功能,将task 中的任务按照系统任务、用户任务依次存放到 system_task 数组和 user_task 数组中(数组中元素的值是任务在task 数组中的下标),并且优先级高的任务排在前面,数组元素为-1表示结束。 例如:task = 0, 30, 155, 1, 80, 300, 170, 40, 99 system_task = 0, 3, 1, 7, -1 user_task = 4, 8, 2, 6, -1 函数接口 void scheduler(int task, int n, int system_task, int user_task)view plaincopy to clipboardprint?1. #include 2. #include 3. #include

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 工作范文

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号