《2014華為校園招聘面試》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在應(yīng)用文檔-天天文庫。
更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/1.輸入整型數(shù)組求數(shù)組的最小數(shù)和最大數(shù)之和,例如輸入1,2,3,4則輸出為5,當(dāng)輸入只有一個(gè)數(shù)的時(shí)候,則最小數(shù)和最大數(shù)都是該數(shù),例如只輸入1,則輸出為2;另外數(shù)組的長度不超過50參考代碼:#include 1更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/????for(intj=0;j 2”,sum);????return0;}??2.求兩個(gè)長長整型的數(shù)據(jù)的和并輸出,例如輸入1233333333333333。。。3111111111111111111111111.。。。,則輸出。。。。?#include 3更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/????char*sum;//????inttemp;intlen_num1,len_num2;//兩個(gè)長長整型數(shù)據(jù)的長度????intlen_max,len_min;????num1=(char*)malloc(sizeof(char));????num2=(char*)malloc(sizeof(char));????printf(“輸入兩個(gè)長長整型數(shù)據(jù):”);????scanf(“%s”,num1);????printf(“輸入兩個(gè)長長整型數(shù)據(jù):”);????scanf(“%s”,num2);????len_num1=strlen(num1);????len_num2=strlen(num2);????len_max=(len_num1>=len_num2)?len_num1:len_num2;????len_min=(len_num1<=len_num2)?len_num1:len_num2;????intlen_max1=len_max;????sum=(char*)malloc(sizeof(char)*len_max);????memset(sum,0×00,len_max+1);//切忌初始化????for(;len_num1>0&&len_num2>0;len_num1–,len_num2–)????{????sum[len_max--]=((num1[len_num1-1]-’0′)+(num2[len_num2-1]-’0′));????} 4更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/????if(len_num1>0)????{????????sum[len_max--]=num1[len_num1-1]-’0′;????????len_num1–;????}????if(len_num2>0)????{????????sum[len_max--]=num1[len_num2-1]-’0′;????????len_num2–;????}????for(intj=len_max1;j>=0;j–)//實(shí)現(xiàn)進(jìn)位操作????{????//????temp=sum[j]-’0′;????????if(sum[j]>=10)????????{????????sum[j-1]+=sum[j]/10;????????????sum[j]%=10;????????}????}????char*outsum=(char*)malloc(sizeof(char)*len_max1);????j=0; 5更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/????while(sum[j]==0)//跳出頭部0元素????????j++;????for(intm=0;m 6”,outsum);????return0;}?3.通過鍵盤輸入一串小寫字母(a~z)組成的字符串。請編寫一個(gè)字符串過濾程序,若字符串中出現(xiàn)多個(gè)相同的字符,將非首次出現(xiàn)的字符過濾掉。比如字符串”abacacde”過濾結(jié)果為”abcde”。要求實(shí)現(xiàn)函數(shù):voidstringFilter(constchar*pInputStr,longlInputLen,char*pOutputStr);【輸入】pInputStr:輸入字符串lInputLen:輸入字符串長度【輸出】pOutputStr:輸出字符串,空間已經(jīng)開辟好,與輸入字符串等長;參考代碼:#include 7更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/voidstringFilter(constchar*p_str,longlen,char*p_outstr){intarray[256]={0};constchar*tmp=p_str;for(intj=0;j 8”,outstr);????free(outstr); 9更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/????outstr=NULL;}?5.通過鍵盤輸入100以內(nèi)正整數(shù)的加、減運(yùn)算式,請編寫一個(gè)程序輸出運(yùn)算結(jié)果字符串。輸入字符串的格式為:”操作數(shù)1運(yùn)算符操作數(shù)2″,”操作數(shù)”與”運(yùn)算符”之間以一個(gè)空格隔開。?補(bǔ)充說明:1.操作數(shù)為正整數(shù),不需要考慮計(jì)算結(jié)果溢出的情況。2.若輸入算式格式錯(cuò)誤,輸出結(jié)果為”0″。?要求實(shí)現(xiàn)函數(shù):voidarithmetic(constchar*pInputStr,longlInputLen,char*pOutputStr);?【輸入】pInputStr:輸入字符串lInputLen:輸入字符串長度【輸出】pOutputStr:輸出字符串,空間已經(jīng)開辟好,與輸入字符串等長;#include 10更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/{????chars1[10];????chars2[10];????chars3[10];????intcnt=0;????intlen_input=strlen(input);????for(inti=0;i 11更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/????{????????*output++=’0′;????????*output=‘\0′;????????return;?????}?????intlen_s1=strlen(s1);????for(i=0;i 12更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/????????if(s3[i]<’0′||s3[i]>’9′)????????{????????????*output++=’0′;????????????*output=‘\0′;????????????return;????????}????}?????intx=atoi(s1);????inty=atoi(s3);????if(s2[0]==’+')????{????????intresult=x+y;????????itoa(result,output,10);????}????elseif(s2[0]==’-')????{????????intresult=x-y;????????itoa(result,output,10);????}????else 13更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/????{????????*output++=’0′;????????*output=‘\0′;????????return;?????}?}voidmain(){????charstr[]={“10–23″};????charoutstr[10];????intlen=strlen(str);????arithmetic(str,len,outstr);????printf(“%s 14”,str);????printf(“%s 15”,outstr);????}?6.一組人(n個(gè)),圍成一圈,從某人開始數(shù)到第三個(gè)的人出列,再接著從下一個(gè)人開始數(shù),最終輸出最終出列的人 16更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/(約瑟夫環(huán)是一個(gè)數(shù)學(xué)的應(yīng)用問題:已知n個(gè)人(以編號(hào)1,2,3…n分別表示)圍坐在一張圓桌周圍。從編號(hào)為k的人開始報(bào)數(shù),數(shù)到m的那個(gè)人出列;他的下一個(gè)人又從1開始報(bào)數(shù),數(shù)到m的那個(gè)人又出列;依此規(guī)律重復(fù)下去,直到圓桌周圍的人全部出列。)#include 17更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/????{????????q=(LinkList*)malloc(sizeof(LinkList));????????q->data=i+1;????????p->next=q;????????p=q;????}????p->next=head;//使鏈表尾連接鏈表頭,形成循環(huán)鏈表????returnhead;????free(p);????p=NULL;????free(q);????q=NULL;}?voiddeletefun(LinkList*L,intm){????LinkList*p,*q,*temp;????inti;????p=L;?????while(p->next!=p) 18更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/????{????????for(i=1;i 19”,p->data);}?intmain(){????intn=7,m=3;????LinkList*head1;????head1=create(n);????deletefun(head1,m); 20更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/????return0;}7..輸入一串字符,只包含”0-10″和”,”找出其中最小的數(shù)字和最大的數(shù)字(可能不止一個(gè)),輸出最后剩余數(shù)字個(gè)數(shù)。如輸入“3,3,4,5,6,7,7″#include 21”);????scanf(“%s”,&str);?????intlen=strlen(str);????intarray[100];????intcount=0;????for(inti=0;i 22更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/????}????array[count]=’\0′;????intresult=count;????intmin=array[0];????intmax=array[0];????for(intj=0;j 23”,result);} 24更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/8.輸入一組身高在170到190之間(5個(gè)身高),比較身高差,選出身高差最小的兩個(gè)身高;若身高差相同,選平均身高高的那兩個(gè)身高;從小到大輸出;如輸入170181173186190輸出170173#include 25”);????for(intk=0;k 26”);?????for(i=0;i 27更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/????????????temp=Height[j-1];????????????Height[j-1]=Height[j];????????????Height[j]=temp;????????}?????H1=Height[0];????H2=Height[1];????dmin=H2-H1;????for(intm=2;m 28”);????printf(“%d,%d 29”,H1,H2);????return0;} 30更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/9.刪除子串,只要是原串中有相同的子串就刪掉,不管有多少個(gè),返回子串個(gè)數(shù)。#include 31更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/????????{????????????count++;????????????memset(temp,0×00,n+1);????????????p=p+n;????????}????????else????????{????????????????*t=*p;????????????p++;????????????t++;????????????memset(temp,0×00,n+1);????????}????????}????free(temp);????returncount;}voidmain(){????chars[100]={‘\0′};????intnum=delete_sub_str(“123abc12de234fg1hi34j123k”,”123″,s);????printf(“Thenumberofsub_stris%d\r 32”,num); 33更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/????printf(“Theresultstringis%s\r 34”,s);}10.要求編程實(shí)現(xiàn)上述高精度的十進(jìn)制加法。要求實(shí)現(xiàn)函數(shù):voidadd(constchar*num1,constchar*num2,char*result)【輸入】num1:字符串形式操作數(shù)1,如果操作數(shù)為負(fù),則num1[0]為符號(hào)位’-’num2:字符串形式操作數(shù)2,如果操作數(shù)為負(fù),則num2[0]為符號(hào)位’-’【輸出】result:保存加法計(jì)算結(jié)果字符串,如果結(jié)果為負(fù),則result[0]為符號(hào)位。#include 35更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/?intremove_zero(char*result,intlength){intcount=0;for(inti=length-1;i>0;i–)//從最后開始移除0,直到遇到非0數(shù)字,只對(duì)最初位置上的0不予判斷{if(result[i]==’0′){result[i]=‘\0′;count++;}elsereturnlength-count;}returnlength–count;}?voidreverse(char*result,intlength)//將字符串倒轉(zhuǎn){chartemp;for(inti=0;i<=(length-1)/2;i++){ 36更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/temp=result[i];result[i]=result[length-1-i];result[length-1-i]=temp;}}?intreal_add(char*str1,char*str2,char*result,constboolflag){intlen1=strlen(str1);intlen2=strlen(str2);intn1,n2,another=0;//another表示進(jìn)位intcur_rs=0;//表示result的當(dāng)前位數(shù)inti,j;intcurSum;for(i=len1-1,j=len2-1;i>=0&&j>=0;i–,j–){n1=str1[i]–’0′;n2=str2[j]–’0′;curSum=n1+n2+another;result[cur_rs++]=curSum%10+’0′;another=curSum/10; 37更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/}?if(j<0){while(i>=0)//遍歷str1剩余各位{n1=str1[i--]–’0′;curSum=n1+another;result[cur_rs++]=curSum%10+’0′;another=curSum/10;}if(another!=0)//如果還有進(jìn)位未加上result[cur_rs++]=another+’0′;}????else????{while(j>=0){n2=str2[j--]–’0′;curSum=n2+another;result[cur_rs++]=curSum%10+’0′; 38更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/another=curSum/10;}if(another!=0)result[cur_rs++]=another+’0′;}?result[cur_rs]=‘\0′;?cur_rs=remove_zero(result,cur_rs);if(!flag){result[cur_rs++]=‘-’;result[cur_rs]=‘\0′;}reverse(result,strlen(result));returncur_rs;}??intreal_minus(char*str1,char*str2,char*result)//使用str1減去str2{ 39更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/charbig[100],small[100];intbig_len,sml_len;?intlen1=strlen(str1);intlen2=strlen(str2);boolflag=false;//用于標(biāo)記str2是否比str1大?if(len1 40更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/{char*temp=str1;str1=str2;str2=temp;len1=strlen(str1);len2=strlen(str2);}?intn1,n2,another=0;//another表示是否有借位inti,j;intcur_rs=0;intcurMinus;?for(i=len1-1,j=len2-1;i>=0&&j>=0;i–,j–){n1=str1[i]–’0′;n2=str2[j]–’0′;if(n1>=n2+another){result[cur_rs++]=(n1-n2-another)+’0′;another=0; 41更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/}else{result[cur_rs++]=(n1+10-n2-another)+’0′;another=1;}}?while(i>=0){n1=str1[i--]–’0′;if(another!=0){n1-=another;another=0;}result[cur_rs++]=n1+’0′;}?result[cur_rs]=‘\0′;cur_rs=remove_zero(result,cur_rs); 42更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/if(flag){result[cur_rs++]=‘-’;result[cur_rs]=‘\0′;}reverse(result,cur_rs);?returncur_rs;}?voidaddi(constchar*num1,constchar*num2,char*result){intlen1=strlen(num1);intlen2=strlen(num2);intrs_len;if(!len1||!len2)return;charstr1[100],str2[100];strncpy(str1,num1,len1);str1[len1]=‘\0′;strncpy(str2,num2,len2); 43更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/str2[len2]=‘\0′;?if(str1[0]==‘-’&&str2[0]==‘-’){move(str1,len1);move(str2,len2);rs_len=real_add(str1,str2,result,false);}elseif(str1[0]==‘-’){move(str1,len1);rs_len=real_minus(str2,str1,result);}elseif(str2[0]==‘-’){move(str2,len2);rs_len=real_minus(str1,str2,result);}elsers_len=real_add(str1,str2,result,true);}?//intmain(intargc,char*argv[]) 44更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/intmain(){charnum1[100],num2[100];????printf(“請輸入兩個(gè)整型數(shù)據(jù): 45”);????scanf(“%s%s”,num1,num2);?????charresult[100];memset(result,0,100);addi(num1,num2,result);printf(“%s 46”,result);?return0;}11.描述:10個(gè)學(xué)生考完期末考試評(píng)卷完成后,A老師需要?jiǎng)澇黾案窬€,要求如下:(1)及格線是10的倍數(shù);(2)保證至少有60%的學(xué)生及格;(3)如果所有的學(xué)生都高于60分,則及格線為60分輸入:輸入10個(gè)整數(shù),取值0~100輸出:輸出及格線,10的倍數(shù)#include 47更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/{????inti,j,temp;????for(i=0;i<10;i++)????????for(j=0;j<9-i&&arr[j]>arr[j+1];j++)????????{????????????temp=arr[j];????????????arr[j]=arr[j+1];????????????arr[j+1]=temp;????????}}?intGetPassLine(inta[]){????bubblesort(a);????if(a[0]>=60)????????return60;????else????????return(((int)a[4]/10)*10);}?main() 48更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/{????inta[10]={0};????intresult;????printf(“請隨機(jī)輸入10個(gè)成績(0-100): 49”);????scanf(“%d%d%d%d%d%d%d%d%d%d”,&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8],&a[9]);????printf(“ 50”);????result=GetPassLine(a);????printf(“及格線為:%d 51”,result);????return1;}?12.描述:一條長廊里依次裝有n(1≤n≤65535)盞電燈,從頭到尾編號(hào)1、2、3、…n-1、n。每盞電燈由一個(gè)拉線開關(guān)控制。開始,電燈全部關(guān)著。有n個(gè)學(xué)生從長廊穿過。第一個(gè)學(xué)生把號(hào)碼凡是1的倍數(shù)的電燈的開關(guān)拉一下;接著第二個(gè)學(xué)生把號(hào)碼凡是2的倍數(shù)的電燈的開關(guān)拉一下;接著第三個(gè)學(xué)生把號(hào)碼凡是3的倍數(shù)的電燈的開關(guān)拉一下;如此繼續(xù)下去,最后第n個(gè)學(xué)生把號(hào)碼凡是n的倍數(shù)的電燈的開關(guān)拉一下。n個(gè)學(xué)生按此規(guī)定走完后,長廊里電燈有幾盞亮著。注:電燈數(shù)和學(xué)生數(shù)一致。輸入:電燈的數(shù)量輸出:亮著的電燈數(shù)量樣例輸入:3樣例輸出:1? 52更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/#include 53更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/}intmain(){????intn,result;????printf(“請輸入燈的數(shù)量(1-65535): 54”);????scanf(“%d”,&n);????result=GetLightLampNum(n);????printf(“最后亮燈的數(shù)量為:%d 55”,result);????return0;}13.描述:已知2條地鐵線路,其中A為環(huán)線,B為東西向線路,線路都是雙向的。經(jīng)過的站點(diǎn)名分別如下,兩條線交叉的換乘點(diǎn)用T1、T2表示。編寫程序,任意輸入兩個(gè)站點(diǎn)名稱,輸出乘坐地鐵最少需要經(jīng)過的車站數(shù)量(含輸入的起點(diǎn)和終點(diǎn),換乘站點(diǎn)只計(jì)算一次)。地鐵線A(環(huán)線)經(jīng)過車站:A1A2A3A4A5A6A7A8A9T1A10A11A12A13T2A14A15A16A17A18地鐵線B(直線)經(jīng)過車站:B1B2B3B4B5T1B6B7B8B9B10T2B11B12B13B14B15輸入:輸入兩個(gè)不同的站名輸出:輸出最少經(jīng)過的站數(shù),含輸入的起點(diǎn)和終點(diǎn),換乘站點(diǎn)只計(jì)算一次輸入樣例:A1A3輸出樣例:3#include 56更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/#include 57更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/voidcreat(vexnodega[]){inti;edgenode*p;for(i=0;i 58更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/p->adjvex=SUBWAY_A+4;p->next=NULL;ga[i].link->next->next=p;p=(edgenode*)malloc(sizeof(edgenode));p->adjvex=SUBWAY_A+5;p->next=NULL;ga[i].link->next->next->next=p;}elseif(i==14){p=(edgenode*)malloc(sizeof(edgenode));p->adjvex=SUBWAY_A+9;p->next=NULL;ga[i].link->next->next=p;p=(edgenode*)malloc(sizeof(edgenode));p->adjvex=SUBWAY_A+10;p->next=NULL;ga[i].link->next->next->next=p;}}p=(edgenode*)malloc(sizeof(edgenode));p->adjvex=SUBWAY_A-1; 59更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/p->next=NULL;ga[0].link=p;p=(edgenode*)malloc(sizeof(edgenode));p->adjvex=1;p->next=NULL;ga[0].link->next=p;?p=(edgenode*)malloc(sizeof(edgenode));p->adjvex=SUBWAY_A-2;p->next=NULL;ga[SUBWAY_A-1].link=p;p=(edgenode*)malloc(sizeof(edgenode));p->adjvex=0;p->next=NULL;ga[SUBWAY_A-1].link->next=p;?//B地鐵建鄰接表for(i=1;i 60更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/p->next=NULL;ga[i+SUBWAY_A].link=p;p=(edgenode*)malloc(sizeof(edgenode));p->adjvex=SUBWAY_A+i+1;p->next=NULL;ga[i+SUBWAY_A].link->next=p;}p=(edgenode*)malloc(sizeof(edgenode));p->adjvex=SUBWAY_A+3;p->next=NULL;ga[SUBWAY_A+4].link=p;p=(edgenode*)malloc(sizeof(edgenode));p->adjvex=9;p->next=NULL;ga[SUBWAY_A+4].link->next=p;?p=(edgenode*)malloc(sizeof(edgenode));p->adjvex=9;p->next=NULL;ga[SUBWAY_A+5].link=p;p=(edgenode*)malloc(sizeof(edgenode)); 61更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/p->adjvex=SUBWAY_A+6;p->next=NULL;ga[SUBWAY_A+5].link->next=p;?p=(edgenode*)malloc(sizeof(edgenode));p->adjvex=SUBWAY_A+8;p->next=NULL;ga[SUBWAY_A+9].link=p;p=(edgenode*)malloc(sizeof(edgenode));p->adjvex=14;p->next=NULL;ga[SUBWAY_A+9].link->next=p;?p=(edgenode*)malloc(sizeof(edgenode));p->adjvex=14;p->next=NULL;ga[SUBWAY_A+10].link=p;p=(edgenode*)malloc(sizeof(edgenode));p->adjvex=SUBWAY_A+11;p->next=NULL;ga[SUBWAY_A+10].link->next=p; 62更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/?p=(edgenode*)malloc(sizeof(edgenode));p->adjvex=SUBWAY_A+1;p->next=NULL;ga[SUBWAY_A].link=p;?p=(edgenode*)malloc(sizeof(edgenode));p->adjvex=SUBWAY_A+SUBWAY_B-2;p->next=NULL;ga[SUBWAY_A+SUBWAY_B-1].link=p;//打印各鄰接節(jié)點(diǎn)for(i=0;i 63”);} 64更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/?}intmain(){vexnodega[MAX];creat(ga);inti;charstr[2][10];while(scanf(“%s%s”,str[0],str[1])!=EOF){inttemp=0;for(i=0;i 65更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/if(find_flag)break;count++;printf(“************************ 66”);printf(“第%d層搜索:”,count);inttemp_end=end;while(start 67更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/}q.pop();start++;}printf(“ 68”);}printf(“%d 69”,count);}return0;}14.字串轉(zhuǎn)換問題描述:將輸入的字符串(字符串僅包含小寫字母’a'到’z'),按照如下規(guī)則,循環(huán)轉(zhuǎn)換后輸出:a->b,b->c,…,y->z,z->a;若輸入的字符串連續(xù)出現(xiàn)兩個(gè)字母相同時(shí),后一個(gè)字母需要連續(xù)轉(zhuǎn)換2次。例如:aa轉(zhuǎn)換為bc,zz轉(zhuǎn)換為ab;當(dāng)連續(xù)相同字母超過兩個(gè)時(shí),第三個(gè)出現(xiàn)的字母按第一次出現(xiàn)算。要求實(shí)現(xiàn)函數(shù):voidconvert(char*input,char*output)【輸入】char*input,輸入的字符串【輸出】char*output,輸出的字符串【返回】無#include 70更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/{????if(input==NULL)????????return;????chartemp=’\0′;????intlen_input=strlen(input);????inti;????intflag=0;?????for(i=0;i 71更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/????????????????temp=input[i];????????????????flag=0;????????????}????????????else????????????{????????????????output[i]=(input[i]-’a'+1)%26+’a';????????????????temp=input[i];????????????????flag=1;????????????}????????}????}????output[i]=’\0′;}?voidmain(){????char*input=”xyz”;????charoutput[256];//????scanf(“%s”,input);????convert(input,output);????printf(“%s 72”,output); 73更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/}15.在給定字符串中找出單詞(“單詞”由大寫字母和小寫字母字符構(gòu)成,其他非字母字符視為單詞的間隔,如空格、問號(hào)、數(shù)字等等;另外單個(gè)字母不算單詞);找到單詞后,按照長度進(jìn)行降序排序,(排序時(shí)如果長度相同,則按出現(xiàn)的順序進(jìn)行排列),然后輸出到一個(gè)新的字符串中;如果某個(gè)單詞重復(fù)出現(xiàn)多次,則只輸出一次;如果整個(gè)輸入的字符串中沒有找到單詞,請輸出空串。輸出的單詞之間使用一個(gè)”空格”隔開,最后一個(gè)單詞后不加空格。要求實(shí)現(xiàn)函數(shù):voidmy_word(charinput[],charoutput[])【輸入】charinput[],輸入的字符串【輸出】charoutput[],輸出的字符串【返回】無#include 74更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/for(i=0;i 75更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/for(j=1;j<5-i;j++){if(strlen(word[j-1]) 76更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/for(j=0;j<5;j++){if(0==j){strncpy(output,word[j],strlen(word[j])+1);}else{strcat(output,blank);strcat(output,word[j]);}}return;}intmain(){?charinput[]=”somelocalbuses,some1234123drivers”;????printf(“篩選之前的字符串:%s 77”,input);charoutput[30];my_word(input,output); 78更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/printf(“篩選之后的字符串:%s”,output);printf(“ 79”);return0;}16.數(shù)組中數(shù)字都兩兩相同,只有一個(gè)不同,找出該數(shù)字:intfindUnique(int*a,intlen){????inti=1;????inttemp=a[0];????for(;i 80更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/intfindXorSum(int*a,intlen){????inti=0;????inttemp=0;????for(;i 81更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/?intisBit1(inta,intcount){????a=a>>count-1;????return(a&1);????}?voidfindTwoUnique(int*a,intlen){????inti=0;????intm=0,n=0;????inttemp=findXorSum(a,len);????intcount=findFirstBit1(temp);????for(;i 82更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/????????????n=n^a[i];????????}????}????printf(“%d,%d”,m,n);}?intmain(){????findTwoUnique(a,8);}18.鏈表翻轉(zhuǎn)。給出一個(gè)鏈表和一個(gè)數(shù)k,比如鏈表1→2→3→4→5→6,k=2,則翻轉(zhuǎn)后2→1→4→3→6→5,若k=3,翻轉(zhuǎn)后3→2→1→6→5→4,若k=4,翻轉(zhuǎn)后4→3→2→1→5→6,用程序?qū)崿F(xiàn)思想:采用遍歷鏈表,分成length/k組,對(duì)每組進(jìn)行逆轉(zhuǎn),逆轉(zhuǎn)的同時(shí)要將逆轉(zhuǎn)后的尾和頭連接起來//#include“stdafx.h”#include“stdio.h”#include“stdlib.h”#include 83更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/}LinkList;?voidConverse(LinkList*pPre,LinkList*pCur){//鏈表逆轉(zhuǎn)????LinkList*p=NULL;????LinkList*pNext=NULL;????p=pPre->next;????LinkList*p1=NULL;????if(pCur!=NULL)????????pNext=pCur->next;?????while(p!=pNext)????{????????p1=p->next;????????p->next=pPre;????????pPre=p;????????p=p1;????}}?intmain() 84更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/{????intcount=0,k,i=0,j=0,flag=1,length=0,groups=0;????scanf(“%d”,&k);????LinkList*pPre=(LinkList*)malloc(sizeof(LinkList));????LinkList*pCur=(LinkList*)malloc(sizeof(LinkList));????LinkList*pNext=(LinkList*)malloc(sizeof(LinkList));????LinkList*head=NULL;LinkList*pTempTail=NULL;//指向逆轉(zhuǎn)之后的尾部????LinkList*pTempHead=NULL;?????pCur->value=1;????pPre=pCur;//創(chuàng)建初始鏈表????for(i=2;i<=6;i++){????????LinkList*node=(LinkList*)malloc(sizeof(LinkList));????????node->value=i;????????pCur->next=node;????????pCur=node;????}????pCur->next=NULL;//最后一定要置NULL,c++中用new則無須置NULL????????pCur=pPre; 85更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/????while(pCur!=NULL)????{????????length++;????????pCur=pCur->next;????}????i=0;????groups=length/k;//分成K段????pCur=pPre;????while(i<=groups)?????{????????count=0;????????while(count 86更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/????????????if(flag==0)????????????{????????????????pTempTail->next=pTempHead;????????????}????????????pTempTail=pPre;????????????Converse(pPre,pCur);????????????//pTempTail=pPre;????????????if(flag==1)????????????{????????????????head=pCur;????????????????flag=0;????????????}????????????pCur=pNext;????????}????????else????????{????????????pTempTail->next=pNext;????????}????????pPre=pCur;????????i++;????} 87更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/?????????pCur=head;?????while(j 88”);//????system(“pause”);????return0;}19.鏈表相鄰元素翻轉(zhuǎn),如a->b->c->d->e->f-g,翻轉(zhuǎn)后變?yōu)椋篵->a->d->c->f->e->g#include 89更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/}Node;?Node*CreateList(intn);voidTraverslist(Node*pHead);Node*TransNeighbor(Node*pHead);?intmain(){????Node*pHead=CreateList(7);????printf(“beforetransform 90”);????Traverslist(pHead);????TransNeighbor(pHead);????printf(“ 91aftertransform 92”);????Traverslist(pHead);????getchar();????return1;}//創(chuàng)建新鏈表Node*CreateList(intn){????Node*pHead=(Node*)malloc(sizeof(Node));????Node*pTail=pHead;????pTail->pNext=NULL; 93更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/????inti;????for(i=0;i 94更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/????????}else{????????????printf(“->%c”,p->val);????????}????????????????p=p->pNext;????}????return;}?Node*TransNeighbor(Node*pHead){????Node*p=pHead->pNext;????while(p->pNext!=NULL&&p->pNext->pNext!=NULL)????{????????charvalue=p->val;????????p->val=p->pNext->val;????????p->pNext->val=value;????????p=p->pNext->pNext;????}????returnpHead;}20.輸入一串字符串,其中有普通的字符與括號(hào)組成(包括’(’、’)’、’[',']‘),要求驗(yàn)證括號(hào)是否匹配,如果匹配則輸出0、否則輸出1.#include 95更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/#include 96更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/????????????????flag=1;????????????break;????????case(‘]’):????????????if(a[j-1]==’[')????????????{????????????????a[j-1]=’\0′;????????????????j–;????????????}????????????else????????????????flag=1;????????????break;?????????}????????i++;????}????if(j!=0)flag=1;????printf(“%d 97”,flag);????return0;}方法2:#include 98更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/#include 99”);else{st->top=st->top+1; 100更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/st->stack[st->top]=x;}}voidPop(stacknode*st){st->top=st->top-1;}main(){chars[m]=”(()”;inti;printf(“Creatastack! 101”);sp=(stacknode*)malloc(sizeof(stacknode));//?。?!添加的語句Init(sp);printf(“Inputaexpression: 102”);//gets(s);for(i=0;i 103更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/Pop(sp);}if(sp->top==0)printf(“左右括號(hào)是匹配的! 104”);elseprintf(“左右括號(hào)是不匹配的! 105”);return0;}21.將第一行中含有第二行中”23″的數(shù)輸出并排序2.輸入一行數(shù)字:123?423?5645?875?186523在輸入第二行:23將第一行中含有第二行中”23″的數(shù)輸出并排序結(jié)果即:123?423?186523?#include 106更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/????charc=’‘;????i=0;????while(c!=’ 107’)????{????????scanf(“%d%c”,&temp,&c);????????a[i++]=temp;????}????scanf(“%d”,&s);????for(j=0;j 108更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/????????if(sort[j]>sort[j+1])????????{????????????temp=sort[j+1];????????????sort[j+1]=sort[j];????????????sort[j]=temp;????????}????}????for(i=0;i 109”);????return0;}?22輸入m個(gè)字符串?和一個(gè)整數(shù)n,?把字符串M化成以N為單位的段,不足的位數(shù)用0補(bǔ)齊。如?n=8?m=9?,123456789劃分為:1234567890000000123化為?:12300000?#include 110更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/?intmain(){????charc[200]={‘\0′};????scanf(“%s”,&c);????intn,i,j;????intlen=strlen(c);????scanf(“%d”,&n);????for(i=1;i<=len;i++)????{????????j=i%n;????????printf(“%c”,c[i-1]);????????if(j==0)????????????printf(“ 111”);????}????if(j!=0)????for(i=j+1;i<=n;i++)????????printf(“0″);????return0;}? 112更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/23將?電話號(hào)碼?one?two?。。。nine?zero翻譯成1??2?。。9?0中間會(huì)有double例如輸入:OneTwoThree輸出:123輸入:OneTwoDoubleTwo輸出:1222輸入:1Two2輸出:ERROR輸入:DoubleDoubleTwo輸出:ERROR有空格,非法字符,兩個(gè)Double相連,Double位于最后一個(gè)單詞都錯(cuò)誤?#include 113’)????{????????scanf(“%s%c”,&temp,&c); 114更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/????????f=0;????????for(j=0;j<11;j++)????????{????????????if(!strcmp(temp,a[j])&&j<10)????????????{????????????????printf(“%d”,j);????????????????f=1;????????????????if(d==1)????????????????{????????????????????printf(“%d”,j);????????????????????d=0;????????????????}????????????}????????????elseif(!strcmp(temp,a[j])&&j==10)????????????{????????????????d=1;????????????????f=1;????????????}????????}????????if(f==0)????????????break; 115更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/????}????if(d==1||f==0)????????printf(“error 116”);????printf(“ 117”);????return0;}?24.將整數(shù)倒序輸出,剔除重復(fù)數(shù)據(jù)輸入一個(gè)整數(shù),如12336544,或1750,然后從最后一位開始倒過來輸出,最后如果是0,則不輸出,輸出的數(shù)字是不帶重復(fù)數(shù)字的,所以上面的輸出是456321和571。如果是負(fù)數(shù),比如輸入-175,輸出-571。?#include 118更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/????intlen=strlen(input);????if(input[0]==’-')????{????????flag=1;????????for(i=0;i 119更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/????????printf(“-”);?????for(intii=count-1;ii>=0;ii–)????{????????if(n[ii]!=0||flag1!=0)????????{????????????printf(“%d”,n[ii]);????????????flag1=1;????????}????}????printf(“ 120”);????return0;}??25.編程的時(shí)候,if條件里面的”(“、”)”括號(hào)經(jīng)常出現(xiàn)不匹配的情況導(dǎo)致編譯不過,請編寫程序檢測輸入一行if語句中的圓括號(hào)是否匹配正確。同時(shí)輸出語句中出現(xiàn)的左括號(hào)和右括號(hào)數(shù)量,如if((a==1)&&(b==1))是正確的,而if((a==1))&&(b==1))是錯(cuò)誤的。注意if語句的最外面至少有一對(duì)括號(hào)。提示:用堆棧來做。輸入:if((a==1)&&(b==1))輸出:RIGTH33輸入:if((a==1))&&(b==1)) 121更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/輸出:WRONG34?#include 122更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/????????{????????????right++;????????????if(a[k-1]==1&&k>0)????????????{????????????????a[k-1]=0;????????????????k–;????????????}????????????else????????????????flag=0;????????}????????if((i==2&&s[i]!=’(‘)||(i==len-1&&s[i]!=’)'))????????????flag=0;????}????if(a[0]==0&&flag!=0)????????printf(“RIGHT”);????else????????printf(“WRONG”);????printf(“%d%d 123”,left,right);????return0;}? 124更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/約瑟夫問題輸入一個(gè)由隨機(jī)數(shù)組成的數(shù)列(數(shù)列中每個(gè)數(shù)均是大于0的整數(shù),長度已知),和初始計(jì)數(shù)值m。從數(shù)列首位置開始計(jì)數(shù),計(jì)數(shù)到m后,將數(shù)列該位置數(shù)值替換計(jì)數(shù)值m,并將數(shù)列該位置數(shù)值出列,然后從下一位置從新開始計(jì)數(shù),直到數(shù)列所有數(shù)值出列為止。如果計(jì)數(shù)到達(dá)數(shù)列尾段,則返回?cái)?shù)列首位置繼續(xù)計(jì)數(shù)。請編程實(shí)現(xiàn)上述計(jì)數(shù)過程,同時(shí)輸出數(shù)值出列的順序比如:輸入的隨機(jī)數(shù)列為:3,1,2,4,初始計(jì)數(shù)值m=7,從數(shù)列首位置開始計(jì)數(shù)(數(shù)值3所在位置)第一輪計(jì)數(shù)出列數(shù)字為2,計(jì)數(shù)值更新m=2,出列后數(shù)列為3,1,4,從數(shù)值4所在位置從新開始計(jì)數(shù)第二輪計(jì)數(shù)出列數(shù)字為3,計(jì)數(shù)值更新m=3,出列后數(shù)列為1,4,從數(shù)值1所在位置開始計(jì)數(shù)第三輪計(jì)數(shù)出列數(shù)字為1,計(jì)數(shù)值更新m=1,出列后數(shù)列為4,從數(shù)值4所在位置開始計(jì)數(shù)最后一輪計(jì)數(shù)出列數(shù)字為4,計(jì)數(shù)過程完成。輸出數(shù)值出列順序?yàn)椋?,3,1,4。要求實(shí)現(xiàn)函數(shù):voidarray_iterate(intlen,intinput_array[],intm,intoutput_array[])【輸入】intlen:輸入數(shù)列的長度;intintput_array[]:輸入的初始數(shù)列intm:初始計(jì)數(shù)值【輸出】intoutput_array[]:輸出的數(shù)值出列順序【返回】無示例:輸入:intinput_array[]={3,1,2,4},intlen=4,m=7輸出:output_array[]={2,3,1,4}解題思路:每次出列一個(gè)數(shù)值,需要對(duì)m、input_array、output_array、輸出位置outPos、起始位置startPos進(jìn)行更新; 125更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/對(duì)于輸出位置outPos的計(jì)算是關(guān)鍵!通過分析可知,outPos=(startPos+m-1)%num代碼實(shí)現(xiàn):viewplaincopytoclipboardprint?#include 126”);}//input_array:a[0]…a[len-1]voidarray_iterate(intlen,intinput_array[],intm,intoutput_array[]){intstartPos=0;intoutPos;intnIter=len-1;intnum=len;for(;nIter>=0;nIter–){outPos=(m+startPos-1)%num;m=input_array[outPos]; 127更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/startPos=outPos;printf(“outPosis%d,newmis%d 128”,outPos,m);output_array[len-nIter-1]=input_array[outPos];for(inti=outPos;i 129更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/#include 130”,len);?????for(i=0;i 131更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/????????????count++;????????????temp1=(temp1>a[j])?temp1:a[j];????????????printf(“%d%d 132”,a[j],j);????????}????}????printf(“數(shù)字出現(xiàn)次數(shù)為:%d 133”,count);????printf(“最大次數(shù)為:%d 134”,temp1);????return0;}28..字符串首字母轉(zhuǎn)換成大寫舉例:輸入:thisisabook返回:ThisIsABook?#include 135更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/????inti,len;????len=strlen(input);????printf(“變換前的字符串為:%s 136”,input);????for(i=0;i 137”,output);}29.子串分離?題目描述:??通過鍵盤輸入任意一個(gè)字符串序列,字符串可能包含多個(gè)子串,子串以空格分隔。請編寫一個(gè)程序,自動(dòng)分離出各個(gè)子串,并使用’,'將其分隔,并且在最后也補(bǔ)充一個(gè)’,'并將子串存儲(chǔ)。??如果輸入”abcdefghi????d”,結(jié)果將是abc,def,gh,i,d,?要求實(shí)現(xiàn)函數(shù):?? 138更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/voidDivideString(constchar*pInputStr,longlInputLen,char*pOutputStr);?【輸入】?pInputStr:?輸入字符串??????lInputLen:?輸入字符串長度??????????【輸出】?pOutputStr:?輸出字符串,空間已經(jīng)開辟好,與輸入字符串等長;????#include 139更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/*pOutputStr++=*p++;}else{cnt++;p++;if(cnt==1)*pOutputStr++=‘,’;?}}*pOutputStr++=‘,’;*pOutputStr=‘\0′;}?voidmain(){char*str=“abcdefghid”;longlen=strlen(str);char*outstr=(char*)malloc(sizeof(str));//charoutstr[100];DivideString(str,len,outstr); 140更多企業(yè)校園招聘筆試面試試題合集下載:http://bimian.xuanjianghui.com.cn/printf(“%s”,outstr);printf(“ 141”);}
此文檔下載收益歸作者所有