版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
开课学院:计算机学院 考试形式:闭考试时间:2008年1月21日,所需时间:120分钟,任课教师考生: Section1:SingleChoice(2markforeachitem,total20Thefollowingcodefragmentprintsout charc[20]=“\time\\\0will\n”; Inthefollowingassignmentsorinitialization, iswrong.A.chars[]=" B.chars[10];s="C.char*p=" D.char*p;p="Ifallvariableshavebeendefinedanddeclaredinthefollowingprogram,allthevariableswhichcanbeusedinfunctionfun()are voidfun(intx) staticint}intvoidmain( int}x, B.x,y, C. Thefollowingcodefragmentprintsout char*c[3]={“FIRST”,“SECOND”,“THIRD”};printf(“%s”, Theexpressiontojudge“whetherthevariablechisanalphabeticcharacterornot”is A.('a'<=ch<='z')||('A'<=ch<='Z')B.(ch>='a'&&ch<='z')&&(ch>='A'&&ch<=C.(ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z')D.('a'<=ch<='z')&&('A'<=ch<='Z')Therewillbeanerrorifexecutingstatementprintf(" ","A"); D.%ecisacharactervariable.Whichexpressionmakesthevalueofcbeeither1or C.c= D.c=WhichprecedenceofthefollowingoperatorsranksA! B.[ C.? TheoutputofthefollowingCprogramis #include<stdio.h>voidmain( intdoubled=3.4,x;printf("(%0.2f,%d)",x,}A.(0.00, B.(0.85, C.(0.50, D.noneofAfterthefollowingcodefragmentisexecuted,thevalueofvariablesis inti=5,s=0;while(i-->0){if(i%2)s+=i;elses+=i-- Section2:Fillintheblanks(2markforeachitem,total30Thevalueof Thefollowingcodefragmentprintsout Writethedeclaration withtypedefwhichmakesPAasynonym(同义词foracharacterpointerarray,whichcontains10elements.Thefollowingprogramprintsout #include<stdio.h>intf(int{staticintk=0;ints=0;for(;k<m;k++)++s;returns;}voidmain({ints=1;printf("%d#%d#",s,}Thefollowingprogramprintsout voidf(intn,chars[]){staticinti=0; }}{
intx=12345,i=0; }Thefollowingcodefragmentprints for(s=0,p=*(a+1);p<*(a+3);p=p+2)s+=*p;printf(“%d”,Assumethenameoftheexecutablefileoftheprogrambelowis“prog”:#include<stdio.h>intmain(intargc,char*argv[])printf("%s#%s#",argv[0],argv[argc-return}Theoutputis afterexecutingthecommand:progoThefollowingprogramprintsout #definemy_square_add(a,b)(a*a+b*b)#definemy_square_sub(a,b)(a*a-b*b)intmain(){inta=1,b=printf("%d#",my_square_add(a+b,b));printf("%d#",my_square_sub(a+b,b));return0;}Giventhefunctionprototypevoidprint(FILE*input,constcharwhichtakeinputastheinputstreamandoutputasthenameoftheoutputfile.Nowyouneedtoprintthethestandardinputstream(stdin)tothefile“temp.txt”inyourprogram,writethestatementtohandlethattask. Givenathefunctionbelow:voidfoo(intx){for(;x<10;x+=}Nowassumexissetto1,what'sthevalueofxaftercallingfoo(x)somewhere Iftheassociativitiesoftheoperators*and/areright-to-left,thevalueofexpression10*6/5 Thefollowingcodefragmentprintsoutthereverseduppercaseletters(fromZtoA). Thefunctionofthefollowingcodefragmentinti=0,s=0,a[10];s,a[10],*p=a; if(*p<0)Thefollowingcodefragmentprintsout charc='d';intsum=0,k=-1<0<1;switch(c){switch(k)casecase}case'a':case'b':sum+=20;break;case'c':sum+=30;}Thefunctionoff1()isequivalenttothefunctionoff2().voidf1(chars[],chart[]) intwhile(t[i]!='\0'){s[i]=t[i];i++;}}voidf2(char*s,char{while }Section3:Readeachofthefollowingprogramsandanswerquestions(5marksforeachitem,totalmarks:30)Theoutputofthefollowingprogramis #include<stdio.h>void{inti,for(i=0;i<3;i++) for(i=0;i<3;i++)for(j=0;p[i][j]>=’0’&&p[i][j]<=’9’;if((p[i][j]%3)&&(p[i][j]%2==0)) s=10*s+p[i][j]-‘0’;printf(“%d\n”,s);}Theoutputofthefollowingprogramis #include<stdio.h>intf(inta[],int{intthis,that,i,j;for(i=0;i<n;i++){for(j=i;j<n;j++){this+=a[j];if(this>thatthat=}}return}void }Theoutputofthefollowingprogramis #include<stdio.h> intfor(i=0;i<3;i++)s+=*(*a+i);printf("%d#",s);for(i=0;i<3;i++)s+=**(a+i);printf("%d#",}Wheninput:HowAreYou?<ENTER>,theoutputofthefollowingprogramis voidst(chars[]){inti;charch;if(strlen(s)>2)for(i=1;s[i]!='\0';i++){s[i]=ch;}}{charsh[20];}Theoutputofthefollowingprogramis #include<stdio.h>intvoidp(int*x,int{++yz=*x+y;printf("%d,%d,%d#",*x,y,z);}void{intx=1,y=2,z=3;p(&y,x);}Theoutputofthefollowingprogramis #include<stdio.h>intf(inta[],intn,int{inti,j,sum,for(j=0;j<m;j++)max+=a[j];for(i=1;i<n;i++){for(j=0;j<m;j++)sum+=*(a+i*m+j);if(sum>max)}return}void{staticintprintf(“%d”,f(a,3,}Section4:Accordingtothespecification,completeeachprogram(2marksforeachblank,total:20marks)Giventwochaininglisth1andh2,thefollowingfunctionfjointsthelisth2afterlisth1.Forexample,ifh1={1,2,3,4},h2=(5,6,7,8),afterthefunction,h1willbe(1,2,3,4,5,6,7,8):43214321876587321after87321structnodeintstructnodevoidf(structnode*h1,structnode structnodeif(h1==NULL)(1)}while((2)!=NULL)p->next=(3)}Thereisatextfile,whichcontainsanumber(lessthan100)ofpositivedecimalintegers.Writeacommand-lineprogramprog.ctosearchthefileforaninteger.Ifthisintegerisinthefile,theprogramwilloutput“Found”;Otherwise,willoutput”Notfound”Requirements:taketheinputfilenameandthesearchedintegerascommand-lineparameters.ForThecommand-lineproginfile.txtIftheinputtextfileinfile.txtcontainsthefollowing1223745266791933theoutputwillbeIftheinputtextfileinfile.txtcontainsthefollowing TheoutputwillbeNot#include<stdio.h> voidsort(inta[],int /*sortanintegerarrayintotheincreased{inti,index,k,temp;for(k=0;k<n-1;k++){for(i=k+1;i<n;i++) }}intatoi(char /*convertastringto{inti,n,for(i=0;sign=(s[i]=='-')?-if(s[i]=='+'||s[i]=='-')for(n=0;isdigit(s[i]);n=10*n+(s
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 江西育华校2026届初三语文试题二模冲刺试题(八)含解析
- 企业信息化管理升级报告
- 资金安全保障银行承诺书(9篇)
- 2026年城市地下管网智能探测与漏损定位研究
- 2026年应用型本科教育的现状与前景展望
- XX高中国旗下的讲话-用行动书写青春的诗篇
- 历史明清时期的科技与文化 课件-2025-2026学年统编版七年级历史下册
- 2021-2022学年浙江省宁波市余姚市九年级(上)期中科学试卷-带答案详解
- 项目大体积混凝土安全专项施工方案
- 拐卖儿童犯罪协议书人
- 燃料检修潜在风险与预控措施
- 中学生防震减灾知识
- 劳务合同模板电子下载
- 新安全生产法全文-安全生产法全文
- 初中体育-篮球绕杆运球教学课件设计
- 2023年江西环境工程职业学院高职单招(数学)试题库含答案解析
- 《物理(下册)》教学课件-第六章-光现象及其应用
- 苯氨基与硝基化合物中毒
- 麦积山石窟课件
- 分数百分数应用题的复习课件
- 开复工安全检查表
评论
0/150
提交评论