版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
浙江大学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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 工程吊车承租合同范例
- 实木订货合同范例
- 幼儿园冬季汉服课程设计
- 总裁级课程设计
- 幼儿园螺旋花园课程设计
- 学分计算课程设计吗
- 拱坝课程设计目的
- 影视网课程设计感想
- 学生劳动实践课程设计
- 广州个人形象课程设计
- 广东省东莞市2023-2024学年八年级上学期期末英语试题
- 中小学人工智能教育的重要性与知识体系梳理
- 地铁运营公司工务线路质量评定标准
- 感染性休克急诊处理课件
- 历史七年级上学期期末试卷含答案
- 【基于抖音短视频的营销策略分析文献综述2800字(论文)】
- 2021-2022学年度西城区五年级上册英语期末考试试题
- 《组织行为学》(本)形考任务1-4
- 广东省广州市白云区2022-2023学年九年级上学期期末语文试题
- 剧本-进入黑夜的漫长旅程
- 化肥购销合同范本正规范本(通用版)
评论
0/150
提交评论