届华为校园招聘上机考试题目及答案Java和C++两种方式实现Word文件下载.docx
- 文档编号:19980508
- 上传时间:2023-01-13
- 格式:DOCX
- 页数:14
- 大小:18.14KB
届华为校园招聘上机考试题目及答案Java和C++两种方式实现Word文件下载.docx
《届华为校园招聘上机考试题目及答案Java和C++两种方式实现Word文件下载.docx》由会员分享,可在线阅读,更多相关《届华为校园招聘上机考试题目及答案Java和C++两种方式实现Word文件下载.docx(14页珍藏版)》请在冰豆网上搜索。
system_task[]={0,3,1,7,-1}
user_task[]={4,8,2,6,-1}
函数接口
voidscheduler(inttask[],intn,intsystem_task[],intuser_task[])
Java实现:
publicclassTest1{
publicstaticintcal_score(intscore[],intjudge_type[],intn){
intscore_zhuanjia=0;
intscore_dazong=0;
intsum_score=0;
intnum_zhuanjia=0;
intnum_dazong=0;
for(inti=0;
i<
n;
i++){
if(1==judge_type[i]){
score_zhuanjia+=score[i];
num_zhuanjia++;
}
if(2==judge_type[i]){
score_dazong+=score[i];
num_dazong++;
}
}
if(0==num_dazong){
sum_score=score_zhuanjia/num_zhuanjia;
}else{
sum_score=(int)(score_zhuanjia/num_zhuanjia*0.6+score_dazong/num_dazong*0.4);
returnsum_score;
}
publicstaticvoidmain(String[]args){
intscore1[]={90,91,92,93,94,95,96,97,98,99};
intjudge_type1[]={1,1,1,2,2,1,2,1,2,1};
intsum_score1=cal_score(score1,judge_type1,10);
System.out.println(sum_score1);
intscore2[]={90,91,92,93,94};
intjudge_type2[]={1,1,1,1,1};
intsum_score2=cal_score(score2,judge_type2,5);
System.out.println(sum_score2);
}
publicclassTest2{
/**
*@paramargs
*/
publicstaticvoidsort(intinput[],intn,intoutput[]){
int[]flag=newint[n];
int[]num=newint[n];
num[i]=input[i];
if(0!
=n%2){
for(inti=0;
if(0==i%2){
flag[i]=(n+i)/2;
}else{
flag[i]=(n-i)/2-1;
}
for(intj=0;
j<
j++){
if(0==j%2){
flag[j]=(n+j)/2;
flag[j]=(n-j)/2;
for(intii=0;
ii<
n-1;
ii++){
for(intjj=ii+1;
jj<
jj++){
if(num[jj]>
num[ii]){
inttemp=num[ii];
num[ii]=num[jj];
num[jj]=temp;
for(intk=0;
k<
k++){
output[flag[k]]=num[k];
//TODOAuto-generatedmethodstub
int[]input1={3,6,1,9,7};
int[]output1=newint[5];
sort(input1,5,output1);
5;
System.out.println(output1[i]);
System.out.println("
*********************"
);
int[]input2={3,6,1,9,7,8};
int[]output2=newint[6];
sort(input2,6,output2);
for(intj=0;
6;
System.out.println(output2[j]);
publicclassTest3{
publicstaticvoidscheduler(inttask[],intn,intsystem_task[],intuser_task[]){
intn_system=0;
intn_user=0;
if(task[i]<
50){
n_system++;
}else{
if(task[i]>
=50&
&
task[i]<
=255){
n_user++;
int[]num_system=newint[n_system];
int[]num_user=newint[n_user];
intj=0;
intk=0;
for(inti=0;
i<
n;
i++){
if(task[i]<
50){
num_system[j]=task[i];
system_task[j]=i;
j++;
}else{
if(task[i]>
=255){
num_user[k]=task[i];
user_task[k]=i;
k++;
system_task[j]=-1;
user_task[k]=-1;
n_user-1;
for(intjj=ii;
n_user;
if(num_user[ii]>
num_user[jj]){
inttemp1=num_user[ii];
num_user[ii]=num_user[jj];
num_user[jj]=temp1;
inttemp2=user_task[ii];
user_task[ii]=user_task[jj];
user_task[jj]=temp2;
}
n_system-1;
n_system;
if(num_system[ii]>
num_system[jj]){
inttemp1=num_system[ii];
num_system[ii]=num_system[jj];
num_system[jj]=temp1;
inttemp2=system_task[ii];
system_task[ii]=system_task[jj];
system_task[jj]=temp2;
int[]task={0,30,155,1,80,300,170,40,99};
intnum_system=0;
intnum_user=0;
task.length;
num_system++;
num_user++;
int[]system_task=newint[num_system+1];
int[]user_task=newint[num_user+1];
scheduler(task,task.length,system_task,user_task);
system_task.length;
System.out.println(system_task[i]);
********************"
user_task.length;
System.out.println(user_task[j]);
C++实现:
题一:
#include<
iostream>
usingnamespacestd;
intcal_score(intscore[],intjudge_type[],intn);
voidmain(){
intscore1[10]={90,91,92,93,94,95,96,97,98,99};
intjudge_type1[10]={1,1,1,2,2,1,2,1,2,1};
intsum_score1=cal_score(score1,judge_type1,10);
cout<
<
sum_score1<
endl;
intscore2[5]={90,91,92,93,94};
intjudge_type2[5]={1,1,1,1,1};
intsum_score2=cal_score(score2,judge_type2,5);
sum_score2<
intcal_score(intscore[],intjudge_type[],intn){
intscore_zhuanjia=0;
intscore_dazong=0;
intsum_score=0;
intnum_zhuanjia=0;
intnum_dazong=0;
for(inti=0;
if(1==judge_type[i]){
score_zhuanjia+=score[i];
num_zhuanjia++;
if(2==judge_type[i]){
score_dazong+=score[i];
num_dazong++;
if(0==num_dazong){
sum_score=score_zhuanjia/num_zhuanjia;
}else{
sum_score=(int)(score_zhuanjia/num_zhuanjia*0.6+score_dazong/num_dazong*0.4);
returnsum_score;
题二:
voidsort(intinput[],intn,intoutput[]);
intinput1[5]={3,6,1,9,7};
intoutput1[5];
sort(input1,5,output1);
cout<
output1[i]<
"
**************************"
intinput2[6]={3,6,1,9,7,8};
intoutput2[6];
sort(input2,6,output2);
for(intj=0;
output2[j]<
voidsort(intinput[],intn,intoutput[]){
int*flag=newint[n];
int*num=newint[n];
num[i]=input[i];
if(0!
if(0==i%2){
flag[i]=(n+i)/2;
flag[i]=(n-i)/2-1;
if(0==j%2){
flag[j]=(n+j)/2;
flag[j]=(n-j)/2;
for(intii=0;
for(intjj=ii+1;
if(num[jj]>
inttemp=num[ii];
num[ii]=num[jj];
num[jj]=temp;
for(intk=0;
output[flag[k]]=num[k];
题三:
voidscheduler(inttask[],intn,intsystem_task[],intuser_task[]);
inttask[]={0,30,155,1,80,300,170,40,99};
9;
int*system_task=newint[num_system+1];
int*user_task=newint[num_user+1];
scheduler(task,9,system_task,user_task);
num_system+1;
cout<
system_task[k]<
*******************************"
num_user+1;
user_task[j]<
voidscheduler(inttask[],intn,intsystem_task[],intuser_task[]){
int*num_system=newint[n_system];
int*num_user=newint[n_user];
for(intij=0;
ij<
ij++){
if(task[ij]<
num_system[j]=task[ij];
system_task[j]=ij;
if(task[ij]>
task[ij]<
num_user[k]=task[ij];
user_task[k]=ij;
for(intiii=0;
iii<
iii++){
for(intjj=iii;
if(num_system[iii]>
inttemp1=num_system[iii];
num_system[iii]=num_system[jj];
inttemp2=system_task[iii];
system_task[iii]=system_task[jj];
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 华为 校园 招聘 上机 考试 题目 答案 Java C+ 方式 实现