欢迎来到天天文库
浏览记录
ID:42550360
大小:131.50 KB
页数:14页
时间:2019-09-17
《华为校园招聘上机考试题》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、华为校园招聘上机考试题目(9月6日下午1点场)在网上看到华为在有的地方已经开始机试了,于是决定自己先编着试试。下面是题目和自己写的代码。 1、选秀节目打分,分为专家评委和大众评委,score[]数组里面存储每个评委打的分数,judge_type[]里存储与score[]数组对应的评委类别,judge_type[i]==1,表示专家评委,judge_type[i]==2,表示大众评委,n表示评委总数。打分规则如下:专家评委和大众评委的分数先分别取一个平均分(平均分取整),然后,总分=专家评委平均分 * 0.6+大众评委*0.4,总分取整。如果没有大众评委,则总分=专
2、家评委平均分,总分取整。函数最终返回选手得分。 函数接口 intcal_score(intscore[],intjudge_type[],intn) viewplaincopytoclipboardprint?1.#include 2.#include 3.#include 4.#include 5.#define N 5 6. 7.int cal_score(int score[], int judge_type[], int n) 8. 9.{ 10.
3、int expert=0; 11. int dazhong=0; 12. int zongfen=0; 13. int i; 14. int number=0; 15. 16. for(i=0;i4、hong=dazhong+score[i]; 4. } 5. if(number==N) 6. { 7. zongfen=(int)(expert/N); 8. } 9. else 10. 11. { 12. expert=(int)(expert/number); 13. dazhong=(int)(dazhong/(N-number)); 14. zongfen=int(0.6*expert+0.4*dazhong); 15. 5、 16. } 17. return zongfen; 18. 19.} 20.int main() 21.{ 22. int score[N]; 23. int judge_type[N]; 24. int numberlast=0; 25. int i; 26. printf("please input the %d score:",N); 27. for(i=0;i6、printf("please input the level(1:expert,2:dazhong)"); 30. for(i=0;i7、91pleaseinputthelevel(1:expert,2:dazhong)12111thelastscoreis852、给定一个数组input[],如果数组长度n为奇数,则将数组中最大的元素放到output[]数组最中间的位置,如果数组长度n为偶数,则将数组中最大的元素放到output[]数组中间两个位置偏右的那个位置上,然后再按从大到小的顺序,依次在第一个位置的两边,按照一左一右的顺序,依次存放剩下的数。 例如:input[]={3,6,1,9,7} output[]={3,7,9,6,1}; input[]={3,6,18、,9,7,
4、hong=dazhong+score[i]; 4. } 5. if(number==N) 6. { 7. zongfen=(int)(expert/N); 8. } 9. else 10. 11. { 12. expert=(int)(expert/number); 13. dazhong=(int)(dazhong/(N-number)); 14. zongfen=int(0.6*expert+0.4*dazhong); 15.
5、 16. } 17. return zongfen; 18. 19.} 20.int main() 21.{ 22. int score[N]; 23. int judge_type[N]; 24. int numberlast=0; 25. int i; 26. printf("please input the %d score:",N); 27. for(i=0;i6、printf("please input the level(1:expert,2:dazhong)"); 30. for(i=0;i7、91pleaseinputthelevel(1:expert,2:dazhong)12111thelastscoreis852、给定一个数组input[],如果数组长度n为奇数,则将数组中最大的元素放到output[]数组最中间的位置,如果数组长度n为偶数,则将数组中最大的元素放到output[]数组中间两个位置偏右的那个位置上,然后再按从大到小的顺序,依次在第一个位置的两边,按照一左一右的顺序,依次存放剩下的数。 例如:input[]={3,6,1,9,7} output[]={3,7,9,6,1}; input[]={3,6,18、,9,7,
6、printf("please input the level(1:expert,2:dazhong)"); 30. for(i=0;i7、91pleaseinputthelevel(1:expert,2:dazhong)12111thelastscoreis852、给定一个数组input[],如果数组长度n为奇数,则将数组中最大的元素放到output[]数组最中间的位置,如果数组长度n为偶数,则将数组中最大的元素放到output[]数组中间两个位置偏右的那个位置上,然后再按从大到小的顺序,依次在第一个位置的两边,按照一左一右的顺序,依次存放剩下的数。 例如:input[]={3,6,1,9,7} output[]={3,7,9,6,1}; input[]={3,6,18、,9,7,
7、91pleaseinputthelevel(1:expert,2:dazhong)12111thelastscoreis852、给定一个数组input[],如果数组长度n为奇数,则将数组中最大的元素放到output[]数组最中间的位置,如果数组长度n为偶数,则将数组中最大的元素放到output[]数组中间两个位置偏右的那个位置上,然后再按从大到小的顺序,依次在第一个位置的两边,按照一左一右的顺序,依次存放剩下的数。 例如:input[]={3,6,1,9,7} output[]={3,7,9,6,1}; input[]={3,6,1
8、,9,7,
此文档下载收益归作者所有