




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
浙江大學2011–2012學年春夏學期《程序設計基礎及實驗》課程期末考試試卷課程號:21186020,開課學院:計算機學院.考試試卷:√A卷、B卷(請在選定項上打√)考試形式:√閉、開卷(請在選定項上打√),允許帶∕入場考試日期:2012年06月17日,考試時間:120分鐘誠信考試,沉著應考,杜絕違紀.考生姓名:學號:所屬院系:_(注意:答題內容必須寫在答題卷上,寫在本試題卷上無效)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[0]C.a++D.a+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等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025標準租賃合同簡化版范本
- 2025年簡約個人汽車租賃合同樣本簡明
- 2025辦公室租賃合同范本樣式
- 2025年黑龍江貨車資格證試題及答案
- 北京華富國潤匯銀股權投資合伙企業(有限合伙)
- 2025年深圳勞動合同范本
- 班級文化墻的設計與實現計劃
- 健康快樂的幼兒園小班班級工作計劃
- 2025上海市租賃合同(I)
- 社會責任報告月度準備計劃
- MOOC 思辨式英文寫作-南開大學 中國大學慕課答案
- 辦公室安全用電培訓
- 國家安全+你我共筑-415國家安全教育主題班會課件
- 雪鐵龍DS6說明書
- 餐飲前廳服務培訓課件
- Unit7ArtLesson3AMusicalGenius(第一課時)教學設計高中英語北師大版
- 小學綜合實踐活動《業體驗及其他活動 走進愛國主義教育基地、國防教育場所》
- 圍擋維修施工方案
- 團隊境內旅游合同
- 常用的航運和租船英文縮寫
- 畢業設計(論文)-基于PLC的礦井通風機控制系統設計
評論
0/150
提交評論