2023屆華為校園招聘上機考試題_第1頁
2023屆華為校園招聘上機考試題_第2頁
2023屆華為校園招聘上機考試題_第3頁
2023屆華為校園招聘上機考試題_第4頁
2023屆華為校園招聘上機考試題_第5頁
已閱讀5頁,還剩7頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、2023屆華為校園招聘上機考試題目9月6日下午1點場分類: 華為準備2023-09-08 15:10281人閱讀 HYPERLINK :/ l comments#comments 評論(0)收藏HYPERLINK :/ l report#report o 舉報舉報在網(wǎng)上看到華為在有的地方已經(jīng)開始機試了,于是決定自己先編著試試。下面是題目和自己寫的代碼。1、選秀節(jié)目打分,分為專家評委和群眾評委,score 數(shù)組里面存儲每個評委打的分數(shù),judge_type 里存儲與 score 數(shù)組對應的評委類別,judge_typei = 1,表示專家評委,judge_typei = 2,表示群眾評委,n表示

2、評委總數(shù)。打分規(guī)那么如下:專家評委和群眾評委的分數(shù)先分別取一個平均分平均分取整,然后,總分 = 專家評委平均分 *0.6 + 群眾評委 * 0.4,總分取整。如果沒有群眾評委,那么 總分 = 專家評委平均分,總分取整。函數(shù)最終返回選手得分。函數(shù)接口 int cal_score(int score, int judge_type, int n) HYPERLINK :/ l # o view plain view plaincopy to clipboard HYPERLINK :/ l # o print print HYPERLINK :/ l # o ? ?#include #includ

3、e #include #include #defineN5 intcal_score(intscore,intjudge_type,intn)intexpert=0;intdazhong=0;intzongfen=0;inti;intnumber=0;for(i=0;iN;i+)if(judge_typei=1)expert=expert+scorei;number+;elsedazhong=dazhong+scorei;if(number=N)zongfen=(int)(expert/N);elseexpert=(int)(expert/number);dazhong=(int)(dazho

4、ng/(N-number);zongfen=int(0.6*expert+0.4*dazhong);returnzongfen;intmain()intscoreN;intjudge_typeN;intnumberlast=0;inti;printf(pleaseinputthe%dscore:n,N);for(i=0;iN;i+)scanf(%d,&scorei);printf(pleaseinputthelevel(1:expert,2:dazhong)n);for(i=0;iN;i+)scanf(%d,&judge_typei);numberlast=cal_score(score,ju

5、dge_type,N);printf(thelastscoreis%dn,numberlast);return0;運行結果分析: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、給定一個數(shù)組input ,如果數(shù)組長度n為奇數(shù),那么將數(shù)組中最大的元素放到 output 數(shù)組最中間的位置,如果數(shù)組長度n為偶數(shù),那么將數(shù)組中最大的元素放到 output 數(shù)組中間兩個位置偏右的那個位置上,然后再按從大到小的順序,依次在第一個位置

6、的兩邊,按照一左一右的順序,依次存放剩下的數(shù)。 例如: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, 3 HYPERLINK :/ l # o view plain view plain HYPERLINK :/ l # o copy to clipboard copy to clipboard HYPERLINK :/ l # o print print HYPERLINK :/ l # o ? ?#include #include #include v

7、oidsort(intinput,intn,intoutput)inti,j;intk=1;inttemp;intmed;for(i=0;in;i+)for(j=0;jinputj+1)temp=inputj;inputj=inputj+1;inputj+1=temp;if(n%2!=0)for(i=0;in;i+)printf(%2d,inputi);printf(n);med=(n-1)/2;outputmed=inputn-1;for(i=1;i=med;i+)outputmed-i=inputn-1-k;outputmed+i=inputn-2-k;k=k+2;elsefor(i=0;

8、in;i+)printf(%2d,inputi);printf(n);med=n/2;outputmed=inputn-1;for(i=1;i=med-1;i+)outputmed-i=inputn-1-k;outputmed+i=inputn-2-k;k=k+2;output0=input0;for(i=0;in;i+)printf(%2d,outputi);printf(n);intmain()inta6=3,6,1,9,7,8;intb6=0;for(inti=0;i6;i+)printf(%2d,ai);printf(n);sort(a,6,b);return0;運行結果3 6 1 9

9、 7 81 3 6 7 8 91 6 8 9 7 33、操作系統(tǒng)任務調度問題。操作系統(tǒng)任務分為系統(tǒng)任務和用戶任務兩種。其中,系統(tǒng)任務的優(yōu)先級 = 50且 = 255。優(yōu)先級大于255的為非法任務,應予以剔除?,F(xiàn)有一任務隊列task,長度為n,task中的元素值表示任務的優(yōu)先級,數(shù)值越小,優(yōu)先級越高。函數(shù)scheduler實現(xiàn)如下功能,將task 中的任務按照系統(tǒng)任務、用戶任務依次存放到 system_task 數(shù)組和 user_task 數(shù)組中數(shù)組中元素的值是任務在task 數(shù)組中的下標,并且優(yōu)先級高的任務排在前面,數(shù)組元素為-1表示結束。 例如:task = 0, 30, 155, 1, 8

10、0, 300, 170, 40, 99 system_task = 0, 3, 1, 7, -1 user_task = 4, 8, 2, 6, -1函數(shù)接口 void scheduler(int task, int n, int system_task, int user_task) HYPERLINK :/ l # o view plain view plain HYPERLINK :/ l # o copy to clipboard copy to clipboard HYPERLINK :/ l # o print print HYPERLINK :/ l # o ? ?#includ

11、e #include #include #include voidscheduler1(inttask,intn,intsystem_task,intuser_task)inti;intj=0;int*p,*pp,*p_user,*pp_user;intindex=0;intcount,count2;intmin=0;intk=0;p=(int*)malloc(sizeof(int)*n);for(i=0;in;i+)pi=0;pp=(int*)malloc(sizeof(int)*n);for(i=0;in;i+)ppi=0;p_user=(int*)malloc(sizeof(int)*n

12、);for(i=0;in;i+)p_useri=0;pp_user=(int*)malloc(sizeof(int)*n);for(i=0;in;i+)pp_useri=0;for(i=0;in;i+)if(taski50)system_taskj=taski;ppj=i;j+;count=j;elseif(taski=255)user_taskk=taski;pp_userk=i;k+;count2=k;elsetaski=taski;for(i=0;icount;i+)printf(%3d,system_taski);printf(n);for(i=0;icount;i+)min=syst

13、em_task0;for(j=1;jcount;j+)if(system_taskjmin)min=system_taskj;pi=j;system_taskpi=51;ppcount=-1;for(i=0;icount;i+)printf(%3d,pppi);printf(%3dn,ppcount);/*/for(i=0;icount2;i+)printf(%4d,user_taski);printf(n);for(i=0;icount2;i+)min=user_task0;for(j=1;jcount2;j+)if(user_taskjmin)min=user_taskj;p_useri=

14、j;user_taskp_useri=256;pp_usercount2=-1;for(i=0;icount2;i+)printf(%4d,pp_userp_useri);printf(%3dn,pp_usercount2);intmain()inttask9=0,30,155,1,80,300,170,40,99;intsystem_task9=0;intuser_task9=0;scheduler1(task,9,system_task,user_task);return0;運行結果:0 30 1 400 3 1 7 -1155 80 170 994 8 2 6 -12023華為校園招聘機

15、試成都-1第一道就是說算分數(shù)的問題,去掉一個最高分一個最低分,求平均分view plain HYPERLINK :/ l # o copy to clipboard copy to clipboard HYPERLINK :/ l # o print print HYPERLINK :/ l # o ? ?#include floatavescore(floatscore,intn)floatmin=0;floatmax=0;intminindex=0;intmaxindex=0;floatsum=0;min=score0;for(inti=0;in;i+)if(scoreimin)min=s

16、corei;minindex=i;scoreminindex=0;max=score0;for(i=0;imax)max=scorei;maxindex=i;scoremaxindex=0;for(i=0;in;i+)sum+=scorei;sum=sum/(n-2);returnsum;voidmain()floatscore6=70,80,90,98,87,86;floatlastscore;lastscore=avescore(score,6);printf(thelastscoreis:%5.2fn,lastscore);運行結果:the last score is :85.75202

17、3華為校園招聘機試成都-2分類: 華為準備2023-09-08 22:23324人閱讀評論(2)收藏HYPERLINK :/ l report#report o 舉報舉報第二道:對一個數(shù)組,將數(shù)組中偶數(shù)從大到小排序,奇數(shù)從小到大排序,奇數(shù)和偶數(shù)交叉著放且輸出數(shù)組第一位放奇數(shù) 假設奇數(shù)和偶數(shù)不等長,那么把剩下的直接放到數(shù)組中。-思路:先進行奇偶判斷,得到奇數(shù)和偶數(shù)數(shù)組。然后對兩數(shù)組排序,進行長度判斷,最后組織數(shù)據(jù)。 HYPERLINK :/ l # o view plain view plain HYPERLINK :/ l # o copy to clipboard copy to clipb

18、oard HYPERLINK :/ l # o print print HYPERLINK :/ l # o ? ?#include #include voidjiou(inta,intn)int*p1;int*p2;inti,j;intk=0;intkk=0;intcount1=0;intcount2=0;inttemp;inttemp2;intm=0;p1=(int*)malloc(sizeof(int)*n);p2=(int*)malloc(sizeof(int)*n);for(i=0;in;i+)p1i=0;p2i=0;for(i=0;in;i+)if(ai%2)!=0)p2kk+=ai;elsep1k+=ai;count1=k;count2=kk;for(i=0;icount2;i+)printf(%3d,p2i);printf(n);for(i

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論