版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
浙江大學(xué)2011–2012學(xué)年春夏學(xué)期《程序設(shè)計(jì)基礎(chǔ)及實(shí)驗(yàn)》課程期末考試試卷課程號(hào):21186020,開課學(xué)院:計(jì)算機(jī)學(xué)院.考試試卷:√A卷、B卷(請(qǐng)?jiān)谶x定項(xiàng)上打√)考試形式:√閉、開卷(請(qǐng)?jiān)谶x定項(xiàng)上打√),允許帶∕入場(chǎng)考試日期:2012年06月17日,考試時(shí)間:120分鐘誠信考試,沉著應(yīng)考,杜絕違紀(jì).考生姓名:學(xué)號(hào):所屬院系:_(注意:答題內(nèi)容必須寫在答題卷上,寫在本試題卷上無效)Section1:SingleChoice(2markforeachitem,total20marks)Thearrayinthemainfunctionisinta[10],anditincludesfunctionf(a),thewrongdeclarationoffis_______.A.voidf(intx[10]);B.voidf(intx[]);C.voidf(intx);D.voidf(int*x);AccordingtotheMacro:#defineM5#defineNM+1#defineLN*M/2Afterrunningprintf("%d",L);theoutputis_______.A.5B.7C.12D.15Accordingtothedeclaration:chars[]="1234\0abcd";thevalueofexpressionssizeof(s)andstrlen(s)are_______respectively.A.4和9B.1和9C.10和9D.10和4AccordingtothedeclarationstructH{longid;char*s;};theinvalidstatementofthevariableis_______.A.structHh[5]={{1,"a"},{2,"b"}};B.structHh[5]={{1},{2}};C.structHh[5]={1,"a",2,"b"};D.structHh[5]={1,a,2,b};AccordingtothedeclarationstructVec{intu,v,w,x;}a={2,4,6,8};int*p=&a.u;thevalueofexpressionp[3]is_______.A.2B.4C.6D.8Accordingtothedeclaration"inta[4];“,theinvalidexpressionis_______.A.*aB.a(chǎn)[0]C.a(chǎn)++D.a(chǎn)+1Whatisthevalidrealconstant_______.A.2e1B.1.2EC.E4D.1.0e2.0Theinvalidexpressionfor_______.A.4*u/a/b*xB.4*u*x/b/aC.4*u*x/a*bD.u*x/a/b*4Afterexecutingthefollowingcodefragment,thevaluesofaandbare_______.inta=5,b=1;do{b=a+(a=a>0,a+b);}while(a--);A.-1,7B.0,6C.0,7D.-1,3Accordingtothedeclaration:inty=10;Afterrunningthecodefragmentdo{y--;}while(--y);,yis_______.A.-1B.1C.8D.0Section2:Fillintheblanks(2markforeachitem,total30marks)Readthefollowingcodefragment,f(8)returns_______.intf(intx){ return((x>1)?f(x/2)+1:1);}Afterbeingcompiledandlinked,thefollowingsourcecodefilewillproduceitsexecutablefiletest.exe.Theoutputwillbe_______afterrunningthecommandtest123abc<ENTER>.main(intargc,char*argv[]){printf(“%c#%d#”,*++argv[1],argc);}Thefollowingcodefragmentprintsout_______.voidf(intb,int*c){ b++; *c=*c+b;}intmain(){inta=1,b=2; f(a,&b); printf("%d#%d#",a,b);}Thefollowingprogramsprintsout_______.inta=1,b=2,*pa=&a,*pb=&b,*t;t=pa;pa=pb;pb=t;printf("%d#%d#%d#%d#",a,b,*pa,*pb);Thefollowingcodefragmentprintsout_______.typedefstruct{charname[20],country[10];intcode;}City;typedefstruct{intno;charname[20];Cityaddr;}Contact;Citya={"HZ","CN",86};Contactp={5,"Tom"};p.addr=a;printf("%slivesin%s\n",,);Define“FP”using“typedef”,sothat“FP”isapointerthatpointstothefunctionsthatreturnintergers:_______________.Thefollowingprogramprintsout_______.chars[]=”abc\'\0def\0ghi”,*sp=s;printf(“%s”,sp+5);Thefollowingprogramprintsout_______.#include<stdio.h>intf(intx){staticintk=0;return++k+x;}main(){intk;for(k=0;k<3;k++)printf("%d#",f(k));}Wheninput:HELLOWORLD!<ENTER>,theoutputofthefollowingprogramis_______.chars[20];scanf("%s",s);puts(s);Thefollowingprogramprintsout_______.#include<stdio.h>voidmain(){inta=1,b=-1,c=1;if(b++||--c&&a++)printf("%d#%d#%d#",a,b,c);}Thevalueof-20>>2+3is_______.Forthefollowingdefinition:intx=2;thevalueofdo{printf(“*”);x--;}while(!x==0)is_______.Thefollowingcodefragmentprintsout_______.inti;for(i=0;i<=3;i++)switch(i%3){case0:printf(“*”);break; default:printf(“#”);case1:printf(“&”);}Thefollowingcodefragmentprintsout_______.intx=5,y=0;do{x+=3;y+=x; if(y>40)break;}while(x=16);printf("%d#%d#",x,y);Afterrunningthefollowingcodefragment,thevalueofzis_______.staticstruct{intx,y[3];}a[3]={{1,2,3,4},{5,6,7,8},{9,10,11,12}},*p=a-1;intz;z=*((int*)(p+2)-1);Section3:Readeachofthefollowingprogramsandanswerquestions(5marksforeachitem,totalmarks:30)Wheninput:2187<ENTER>,theoutputofthefollowingprogramis_______.#include<stdio.h>intmain(){intcount=0,i,dig,n,new=0;dig=9;scanf("%d",&n);do{if(n%10<dig)dig=n%10;n=n/10;count++;}while(n!=0);for(i=0;i<count;i++)new=new*10+dig;printf("%d",new);return0;}Theoutputofthefollowingprogramis________.#include<stdio.h>intf(intx,intn,chars[]){staticchart[]="BLACKOUT";intcount;if(x<8){s[n]=t[x];s[n+1]='\0';returnn+1;}count=f(x/8,n,s);count=f(x%8,count,s);returncount;}intmain(){inta=159;chars[100];f(a,0,s);puts(s);return0;}Theoutputofthefollowingprogramis________.#include<stdio.h>#definelength3voidtransposition(intArray[length][length]){ inti,j; intArrayTemp[length][length]; for(i=0;i<length;i++) for(j=0;j<length;j++) ArrayTemp[j][i]=Array[i][j]; for(i=0;i<length;i++) for(j=0;j<length;j++) Array[i][j]=ArrayTemp[i][j];}intmain(){ inti,j; intArray[length][length]={1,3,5,7,9,11,13,15,17}; transposition(Array); for(i=0;i<length;i++) for(j=0;j<length;j++) printf("%d#",Array[i][j]); return0;}Theoutputofthefollowingprogramsis_______.#include<stdio.h>structnode{ intscore;structnode*next;};voidprintcir(structnode*t){ structnode*p=t; do{ printf("%d#",p->score); p=p->next; }while(p!=t);}voidinvrtcir(structnode*node){ structnode*p,*q,*t; p=node;q=p->next; do{ t=q->next; q->next=p; p=q; q=t; }while(p!=node);}intmain(void){staticstructnodeT1[]={0,T1+1,1,T1+2, 2,T1+3, 3,T1}; printcir(T1); invrtcir(T1); printcir(T1);return0;}Wheninput:824211154<ENTER>,theoutputofthefollowingprogramsis_______.#include<stdio.h>intmain(){inta[10];intn,i,j,k;scanf("%d",&n);for(i=0;i<n;i++)scanf("%d",&a[i]);i=0;while(i<n){j=i+1;while(j<n){if(a[j]!=a[i]){j++;continue;}for(k=j;k<n-1;k++)a[k]=a[k+1];a[k]=0;n--}i++;}for(i=0;i<n;i++)printf("%d#",a[i]);}Wheninput52,theoutputofthefollowingprogramsis_______.#include<stdio.h>#include<stdlib.h>structnode{intno;structnode*next;};main(){inti,n,m;structnode*p,*q,*h;scanf("%d%d",&n,&m);for(i=0;i<n;i++){if((p=(structnode*)malloc(sizeof(structnode)))!=NULL){p->no=i+1;if(i==0)h=p,q=p;elseq->next=p,q=p;}}p->next=h;q=p;/*tail*/p=q->next;while(p!=q){for(i=0;i<m;i++){q=p;p=q->next;}q->next=p->next;printf("%d#",p->no);free(p);p=q->next;}printf("%d\n",p->no);}Section4:Accordingtothespecification,completeeachprogram(2markforeachblank,total:20marks)Thefollowingprogramfragmentjudgesifthestringcontains“Hello”iftheinputstringendswith<ENTER>(fewerthan80characters).Youhavetodefineandcallfunctionin(s,t),whichreturns1ifstringscontainsstringt,otherwisereturns0.#include<stdio.h>intin(char*s,char*t){inti,j,k;for(i=0;s[i]!='\0';i++){ (1);if(s[i]==t[j]){ for((2);t[j]!='\0';k++,j++)if((3))break;if(t[j]=='\0')(4); }}return0;}intmain(){chars[80];printf("Enterastring:");gets(s);if((5))printf("\"%s\"includes\"Hello\"\n",s);elseprintf("\"%s\"doesn'tinclude\"Hello\"\n",s);return0;}Thefollowingprogramfragmentcreatesstudent
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 體育運(yùn)動(dòng)彩鋼板安裝合同模板
- 酒店廚師戒煙承諾書范文
- 醫(yī)療機(jī)構(gòu)辦公用品投標(biāo)資料
- 酒店式農(nóng)業(yè)園區(qū)租賃合同范本
- 建筑抗震植筋施工合同
- 建立清晰的人事流程計(jì)劃
- 積木游戲在幼兒園學(xué)習(xí)中的應(yīng)用計(jì)劃
- 專題21我們共同的世界-學(xué)易金卷:5年(2019-2023)中考1年模擬道德與法治分項(xiàng)匯編(安徽專用)(解析版)
- 我國教育博士培養(yǎng)的特征分析:代際嬗變的視角
- 大學(xué)生參觀實(shí)習(xí)報(bào)告15篇
- 牛頓法在圖像處理中的應(yīng)用
- 英語KET官方樣題Test1- Test 2
- 《贏利》精讀圖解
- 2024年一級(jí)造價(jià)工程師考試《建設(shè)工程造價(jià)管理》真題及解析
- 2025屆江蘇揚(yáng)州中學(xué)數(shù)學(xué)高一上期末考試試題含解析
- 2024年認(rèn)證行業(yè)法律法規(guī)及認(rèn)證基礎(chǔ)知識(shí) CCAA年度確認(rèn) 試題與答案
- Unit 1 - Unit 6 知識(shí)點(diǎn)(知識(shí)清單)-2024-2025學(xué)年人教PEP版(2024)英語三年級(jí)上冊(cè)
- 2024 AI專題:從模型視角看端側(cè)AI模型技術(shù)持續(xù)演進(jìn)交互體驗(yàn)有望升級(jí)
- 運(yùn)動(dòng)場(chǎng)捐建協(xié)議書模板
- 子宮脫垂護(hù)理查房-534
- 風(fēng)電項(xiàng)目達(dá)標(biāo)投產(chǎn)升壓站設(shè)備安裝工程質(zhì)量檢查驗(yàn)收表
評(píng)論
0/150
提交評(píng)論