题库语言历年试卷2005a竺院_第1页
题库语言历年试卷2005a竺院_第2页
题库语言历年试卷2005a竺院_第3页
已阅读5页,还剩3页未读 继续免费阅读

付费下载

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

浙江大学2005-2006学年冬季开课学院:计算机学院,考试时间:2006年1月11日,所需时间:120分钟,任课教师考生: (注意:答题内容必须写在答题卷上,写在本试题卷上无效Section1:SingleChoice(2markforeachitem,total20Ifxisafloat thevalueofexpression(x=7/2,x+1)is Thevalueof Thestatement iscorrectifaisanintegervariableandbisadoubleprecisionfloatvariable.scanf(“%d,%f”,&a, B.scanf(“a=%db=%*f”,&a,C.scanf(“%d%*lf”,&a, D.scanf(“%d%*lf”,&aThevalueofexpression strcmp(“internet”,“intranet”) The isequivalent Ifvariablesaredefined, thevalueofexpression isnot1. Ifvariablesaredefinedandassignedcorrectly, theexpression iswrong. Thefollowingcodefragmentprintsout inti=5;while(i--if(i%2)printf("*");elsecontinue;} D.Withregardtothefollowingdefinition:struct{intchar} operator++intheexpression*p++->strisappliedon B.pointerpC.thecontentwhichppoints D.NoneoftheAmongthefollowingstatements, isthemostcorrectstatement.char*p,str[]=“ strcpy(p, Section2:Fillintheblanks(2markforeachitem,total30Ifchisanuppercasecharacter theexpressioncanbewrittenas accordingtothechangingrule:’A’->’Z’,’B’->’Y’,’C’-Thevalueof Thefollowingcodefragmentprintsout printf("%o\n",(010<<1^1)&(0xe<<1));Writeaconditionalexpression tocalculatethevalueofy. - Thefollowingcodefragmentprintsout #defineFB(a,b) intk=3;Afterrunningthefollowingcodefragment,thevalueofais inta=-1,x=10,y=20,ok1=5,ok2=0;if(ok2)Thefollowingcodefragmentprintsout inti,j,k=0;for(i=0,j=10;i<=j;i++,j--)printf("%d,%d,%d",Thefollowingcodefragmentprintsout intk=2,a=1;while(k--!=-1)do}while(k--}Thefollowingcodefragmentprintsout intx=1,y=0,a=0,b=0;switch(x)caseswitch(y)case0:a++;break;case1:b++;}casea++;b++;}Writingthedeclarationwithtypedef,whichmakesNAMEasynonymforacharacterpointerarray,20elements Withthecodefragmentbellow,functioncallf(3),thereturnvalueis f(intn) return((n>0)?f(n-1)+2*f(n-2) Theoutputofthefollowingprogramis #include<stdio.h>int staticintk=0;return}void int printf(“%d”,}Theoutputofthefollowingprogramis #include<stdio.h>{intints(int,int*);}ints(inta,int{intm=*b-=a;returnm;}Inthefollowingcommand-lineprogramrun.c,theoutputafterrunning“run–abc–nlsworld” #include<stdio.h>main(intagrc,char*argv[]){}Afterexecutingthefollowingblock,thevalueofvariableiis staticinta[3][4]={{1,2,3},{4,5,6}},i;i=a[2][-2]+Section3:Readeachofthefollowingprogramsandanswerquestions(5marksforeachitem,totalmarks:30)Theoutputofthefollowingprogramis #include<stdio.h>void{intx,y=-if((z=y)<0)x=4;elseif(y==0)x=5;elsex=6;}Theoutputofthefollowingprogramis #include<stdio.h>intx,y,z;voidp(intx,int int}void x=y=p(y,&x);}Theoutputofthefollowingprogramis #include<stdio.h>voidmain( charch,*s="ACEDB";intx;while(*s!=f(*s++,&x);printf("%d#",x);}}intf(charch,int{*x=0;switch(ch)case'A':*x=95;break;case'B':*x=85;break;case'C':*x=75;break;case'D':*x=60;}}Theoutputofthefollowingprogramis #include<stdio.h>void voiddiv(int*,inta[5]={-1,0,60,45,34},i=0,j=while(a[i]<=0) while(a[i]!=1) div(a+i,&j);}voiddiv(int*n,int if(*n%*k==0)*n/=}else}Theoutputofthefollowingprogramis #include<stdio.h>intf(inta[],int intcur,final,j;for(j=0;j<n;j++){cur+=if(cur>final) final=cur;elseif(cur<0)cur=0;}return}void{ printf(“%d\n”,f(a,}Theoutputofthefollowingprogramis #include<stdio.h>intf(intn,int intn1,m1,result=0;if(n&&m){if(n1==m1)result=f(n/10,elseresult=f(n/10,m/10)*10+((n1>m1)?n1:m1);returnresult; elsereturn}void{}Section4:Accordingtothespecification,completeeachprogram(2markforeachblank,total:20marks)Thefollowingprogramistocalculatethesumofthefirstnitemsofthesequenceas1/2, #include<stdio.h> floatx,y,t,sum=0;inti,n;scanf("%d", ;i++){sum+=x/y; }printf("%f",}Thereisanincreasingorderedcharacterlistinatextfilefile1.Thefollowingprogramreadinthislistcalculatethenumberofduplicates(重复andwriteeachcharacteranditsfrequencyofoccurrence1)(1的出现次数)intothefilefile2.Forexample,ifthefile1containslist“abbcdddeffg”,thelist“ab2cd3ef2g”willbewrittenintofile2.#include<stdio.h> FILE*fp1,*fp2;charlast,c;intif( )exit(0);while( ){if(c!=last)if(count>1) }}}Thereisasimplechaininglisth(maybeNULL).Thefollowingtwofunctions:voidpush(inttoinsertthenintotheheadofthelist,an

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论