2012最新最全華為校園招聘軟件研發(fā)筆試題(2)_第1頁
2012最新最全華為校園招聘軟件研發(fā)筆試題(2)_第2頁
2012最新最全華為校園招聘軟件研發(fā)筆試題(2)_第3頁
2012最新最全華為校園招聘軟件研發(fā)筆試題(2)_第4頁
2012最新最全華為校園招聘軟件研發(fā)筆試題(2)_第5頁
已閱讀5頁,還剩3頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、2012最新最全華為校園招聘軟件研發(fā)筆試題m=p- printf( %5d ,m); output_arrayj+二m;s=p; q-n ext=p- n ext; p=p- n ext; free(s); s=NULL; m=p- / printf( %5dn ,m); output_arrayj=p- k=j; for( j=0 ; j j+) pri ntf( %5d ,output_arrayj); int mai n() int in put_array=3,1,2,4; int len=4; int m=7;int output_array4; array_iterate(le n

2、, in put_array, m); 8、簡單四則運算問題描述:輸入一個只包含個位數(shù)子的簡單四則運算表達式子符串,計算該表達式的值注:1、表達式只含+,-,*,/四則運算符,不含括號2、表達式數(shù)值只包含個位整數(shù)(0-9),且不會出現(xiàn)0作為除數(shù) 的情況3、要考慮加減乘除按通常四則運算規(guī)定的計算優(yōu)先級4、 除法用整數(shù)除法,即僅保留除法運算結(jié)果的整數(shù)部分。比如 8/3=2。輸入表達式保證無0作為除數(shù)情況發(fā)生5、 輸入字符串一定是符合題意合法的表達式, 其中只包括數(shù)字 字符和四則運算符字符,除此之外不含其它任何字符,不會出現(xiàn)計算 溢出情況要求實現(xiàn)函數(shù):int calculate nt len, ch

3、ar *expStr)【輸入】int le n: 字符串長度;char *expStr:表達式字符串;【輸出】無【返回】計算結(jié)果示例1)輸入:char *expStr = 1+4*5-8/3函數(shù)返回:192)輸入:char *expStr = 8/3*3函數(shù)返回:6#in clude #i nclude using n amespace std;intcalculate ntlen ,char *expStr) struct charopdata200;int top; opstack; /定義操作符棧opstack.top-1; int8i=0;遍歷字符串的下標int t=0; 當前后綴表達

4、式的長度 char ch =expStri; while (ch!= 0 ) switch (ch) case + : case - : while (opstack.top != -1) expStrt = opstack.opdataopstack.top; opstack.top-; t+; opstack.top+; opstack.opdataopstack.top = ch; break; case*:case/:while(opstack.top!= -1(opstack.opdataopstack.top=*IIopstack.opdataopstack.top=/ ) ) e

5、xpStrt=opstack.opdataopstack.top;opstack.top-;t+;opstack.top+;opstack.opdataopstack.top=ch; break;default: expStrt = ch; t+; break; i+; ch = expStri; while(opstack.top != -1)/將棧中所有的剩余的運算符出棧 expStrt= opstack.opdataopstack.top;opstack.top-; t+;expStrt= 0 struct int nu meric200; int top; data; data.top

6、=-1; i=0; ch = expStri; while (ch!= 0 ) if (ch = 0 ch = 9 ) data.top+; data .nu mericdata.top = ch- 0 else if( + = ch) int tmp = data .nu mericdata.top-1 + data. nu mericdata.top;data.top-; data .nu mericdata.top = tmp; else if( - = ch) int tmp = data.numericdata.top-1-data .nu mericdata.top;data.to

7、p-;data .nu mericdata.top=tmp; else if( * = ch) int tmp = data .nu mericdata.top-1 * data .nu mericdata.top;data.top-;data .nu mericdata.top=tmp; else if( / = ch) if(data.numericdata.top =0) printf( cannot be zero of the dividen exit(1); int tmp = data .nu mericdata.top-1 / data .nu mericdata.top; d

8、ata.top-;data.numericdata.top = tmp; i+; ch = expStri; return data .nu mericdata.top; void mai n() char expStr = 9/3*5 printf( %sn ,expStr);intresult=calculate(strle n(expStr),expStr);printf( %dn ,result); 9、選秀節(jié)目打分,分為專家評委和大眾評委,score數(shù)組里面存儲每個評委打的分數(shù),judge_type 里存儲與score數(shù)組對 應的評委類別,judge_typei = 1,表示專家評委

9、,judge_typei=2,表示大眾評委,n表示評委總數(shù)。打分規(guī)則如下:專家評委 和大眾評委的分數(shù)先分別取一個平均分(平均分取整),然后,總分二 專家評委平均分* 0.6 +大眾評委* 0.4,總分取整。如果沒有大眾 評委,則 總分二專家評委平均分,總分取整。函數(shù)最終返回選手 得分。函數(shù)接口 int cal_score(int score, int judge_type, int n)#in clude #in clude #i nclude #i nclude #defi ne N 5int cal_score(int score, int judge_type, int n) int e

10、xpert=0; int dazh on g=0; int zongfen=0; int i; int nu mber=0;for(i=0;iif(judge_typei=1)expert二expert+scorei;nu mber+; elsedazho ng二dazh on g+scorei;if(nu mber=N) zongfen二(i nt)(expert/N); else expert=(i nt)(expert/ nu mber);dazho ng=(i nt)(dazh on g/(N-nu mber);zongfen二in t(0.6*expert+0.4*dazh on g

11、); retur n zongfen; int main() int scoreN; int judge_typeN;intnu mberlast=O; int i; printf( please in put the %d score:n ,N); for(i=0;i10、給定一個數(shù)組input,如果數(shù)組長度n為奇數(shù),則將數(shù) 組中最大的元素放到 output 數(shù)組最中間的位置,如果數(shù)組長度n 為偶數(shù),則將數(shù)組中最大的元素放到output 數(shù)組中間兩個位置偏右的那個位置上,然后再按從大到小的順序,依次在第一個位置的兩 邊,按照一左一右的順序,依次存放剩下的數(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 #i nclude #i

溫馨提示

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

評論

0/150

提交評論