<p >1、1、选秀节目打分,分为专家评委和大众评委,score 数组里面存储每个评委打的分数,judge_type 里存储与 score 数组对应的评委类别,judge_typei = 1,表示专家评委,judge_typei = 2,表示大众评委,n表示评委总数。打分规则如下:专家评委和大众评委的分数先分别取一个平均分(平均分取整),然后,总分 = 专家评委平均分 *0.6 + 大众评委 * 0.4,总分取整。如果没有大众评委,则 总分 = 专家评委平均分,总分取整。函数最终返回选手得分。函数接口 int cal_score(int score, int judge_type, int n) #inc</p> <p >2、ludeint cal_score(int score, int judge_type, int n) int i =0;int sum1=0, sum2=0;int count1=0,count2=0;int zhongfen=0;for(i =0; in; i+)if(1=judge_typei) sum1+=scorei; count1+;else /if(2=judge_typei) sum2+=scorei;count2+;if(count2=0) zhongfen = sum1;elsezhongfen = int (sum1/count1)*0.6 +(sum2/count2)*</p> <p >3、0.4); return zhongfen;int main()int score=1,1,1,1,1,1;int judge_type = 2,2,2,1,2,2;printf(%d,cal_score(score, judge_type, 6) ); 2、给定一个数组input ,如果数组长度n为奇数,则将数组中最大的元素放到 output 数组最中间的位置,如果数组长度n为偶数,则将数组中最大的元素放到 output 数组中间两个位置偏右的那个位置上,然后再按从大到小的顺序,依次在第一个位置的两边,按照一左一右的顺序,依次存放剩下的数。 例如:input = 3, 6, 1, 9, 7 </p> <p >4、output = 3, 7, 9, 6, 1; input = 3, 6, 1, 9, 7, 8 output =1, 6, 8, 9, 7, 3函数接口 void sort(int input, int n, int output) #includevoid sort(int input, int n, int output) int i,j; int temp =0; for(i =0; in-1; i+) for(j =0; jinputj+1) temp = inputj;inputj = inputj+1; inputj+1 = temp; if(n%2 =0) for(i =0 ;</p> <p >5、 in/2; i+) outputi = input2*i; for(i =0; in/2; i+) outputn/2+i = inputn-1-2*i; else for(i=0; i(n-1)/2; i+) outputi = input2*i+1; output(n-1)/2= inputn-1; for(i = 0; i(n-1)/2; i+) output(n-1)/2+1+i = inputn-3-2*i; for(i = 0 ; in; i+)printf(%d, outputi);printf(n);int main()int input1 = 3, 6, 1, 9, 7;i</p> <p >6、nt input2 = 3, 6, 1, 9, 7, 8; int output15 = 0; intoutput26 = 0; sort( input1, 5,output1) ;sort(input2, 6, output2) ; 3、操作系统任务调度问题。操作系统任务分为系统任务和用户任务两种。其中,系统任务的优先级 = 50且 = 255。优先级大于255的为非法任务,应予以剔除。现有一任务队列task,长度为n,task中的元素值表示任务的优先级,数值越小,优先级越高。函数scheduler实现如下功能,将task 中的任务按照系统任务、用户任务依次存放到 system_task 数</p> <p >7、组和 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#includestruct Tableint number;int value;void scheduler(int task, int system_task, int user_task,int </p> <p >8、n)int i ;int j;struct Table temp; /struct Table tablen;/n 必需为常量struct Table *table = (struct Table *)malloc(sizeof(struct Table)*n);int system_count=0,user_count=0;for(i =0; in; i+)tablei.number=i;tablei.value =taski;for(i=0; in-1; i+)for(j=0; jtablej+1.value)temp=tablej;tablej= tablej+1;tablej+1 = </p> <p >9、temp;for(i=0; in;i+)if(tablei.value50)system_tasksystem_count = tablei.number;system_count+;else if(tablei.value=250)user_taskuser_count=tablei.number;user_count+;system_tasksystem_count=-1;user_taskuser_count= -1;free(table);int main()int task = 0, 30, 155, 1, 80, 300, 170, 40, 99; int n=9;for(int </p> <p >10、i=0,count_sys=0,count_user=0;i9;i+)if(taski50)count_sys+;else if(taski=255)count_user+;elsecontinue;int *system_task=(int *)malloc(count_sys*sizeof(int)+4);int *user_task=(int *)malloc(count_user*sizeof(int)+4); scheduler(task, system_task, user_task,9);int *p = system_task;int *q = user_task;printf(%d%dn, count_sy</p>
讯享网

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/136418.html