版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
浙江大学2006-2007学年夏季学开课学院:计算机学院 考试形式:闭考试时间:2007年7月7日,所需时间:120分钟,任课教师考生: (注意:答题内容必须写在答题卷上,写在本试题卷上无效Section1:SingleChoice(2marksforeachitem,total20Inthefollowings, isthecorrectcharacter Accordingtothedeclaration:floatx=3;thevalue expressionx=(int)x/2*2is Inthefollowingoperators, hasthemosthighlevelofprecedence. Toexpresswhetherthecharactervariablechisuppercaseletter, isthecorrect Thefollowingprogramfragmentwillprintout intn=0;while(n++<=2); D.syntaxTheexpression!Eofthestatementwhile(!E);isequivalentto Inthefollowingstatements, can’tinitializethetwo-dimensionarrayacorrectly.A.inta[2][3]={0}; B.inta[][3]={{1,2},{0}};C.int D.intTojudgewhetherthecharacterstringaisthesameasb,thecorrectcodefragment if B.ifC.if D.ifGiventhefollowingdeclaritions:inta=10,b=20,*p1=&a,*p2=&b;asshowninfigure1.Ifwewanttogettheresultsasshowninfigure2,wemustchoosethecorrectassignmentstatement figure figure Accordingtothedeclaritionandstatement:inta[2][3],(*p)[3];p=a;thecorrectreferencetotheelementofarrayais Section2:Fillintheblanks(2marksforeachitem,total30Accordingtothedeclarations:intm=5;y=2;thevalueofthevariableyis aftercalculatingtheexpressiony+=y-=m*=y.Accordingtothedeclarations:inta=3,b=2,c=1;Thevalueofexpressiona>b>cis Accordingtothedeclarations:intx,y,z;Theexpressiontodescribe“twoofx,yandzarenegative”is Accordingtothedeclarations:inta=1,b=0;thevalueof ++a*--a==b?12%5:’x’ Wheninput2473<CR>fromkeyboard,thefollowingprogramwillprintout #include<stdio.h>void{intc;switch(c-‘2’)casecase1:case2:putchar(c+4);break;case3:putchar(c+3);default:putchar(c+2);break;}}Thefollowingprogramprintsout #include<stdio.h>intintf(int{staticintfor(;k<=m;k++)s++;returns;}voidmain({ints=1;printf("%d#%d#",s,}Accordingtothefunctiondeclarition:voidmain(intargc,char*argv[])inthefilelearn.c,runthecommand:learntheCprogramminglanguage,thevalueofexpression Thefollowingprogramfragmentprintsout charstr[]=”abc\0def\0ghi”,*p=str;Accordingtothedeclarations:inta[2][3]={2,4,6,8,10,12},*p=a;thevalueofexpression*(p+5)is Assumethatthetwo-dimensionarrayahasmcolumns,thenumberoftheelementsbeforea[i][j]is Thefollowingprogramfragmentprintsout swap(int*p1,int*p2){intp=p1;p1=p2;}inta=5,b=7;Theexpression istotestwhetherthe6thbitofcharactervariablechis1(Assumethatthemost-rightbitisthe1stbit).UsetypedeftodefineapointertypePAthatpointstoanone-dimensionarraywhichcontains10elementsoftypeint Forthefollowingrecursionfunctionf,thefunctioncallf(3)willreturn f(intn) return((n>0)?2*f(n-1)+f(n-2):- Forthefollowingdefinitions,thevalueofexpressionpn->b/n.a*++pn->b is struct{inta;int}}}Section3:Readeachofthefollowingprogramsandanswerquestions(5marksforeachitem,totalmarks:30)Theoutputofthefollowingprogramis #include<stdio.h>void{intintfor(i=0;i<10-n;i++){for(j=i+1;j<10-n;j++)if(a[j]==c){for(k=j;k<10-n;k++)}}for(i=0;i<(10-n);i++)}Theoutputofthefollowingprogramis #definePRIprintf#defineNL“\n”#defineD“%d”#defineD1DNL#defineD2DDNL#defineD3DDDNL#defineD4DDDDNL#defineS“%s”void{inta=1;b=2;c=3;d=4;Theoutputofthefollowingprogramis #include<stdio.h>char*c[]={"ENTER","NEW","POINT",char**cp[]={c+3,c+2,c+1,c};char***cpp=cp;{printf("%s#",**++cpp);printf("%s#",*--*++cpp);}Wheninput6<CR>fromkeyboard,theoutputofthefollowingprogramis #include<stdio.h>#includevoidfun(char*a,charb);voidmain(){chars[]=”97531”,c;}voidfun(char*a,char{}Theoutputofthefollowingprogramis #include<stdio.h>#defineNUM5voidp1(charv[]){intfor(i=1;i<NUM;for(j=i-1;j>=0&&v[j]<v[j+1];j--temp=v[j],v[j]=v[j+1],voidp2(charv1[],char{inti=0,while(i<NUM&&if(v1[i]>v2[j])putchar(v1[i++]); while(i<NUM)putchar(v1[i++]);while(j<NUM)}void{chars[2][5]={‘v’,’d’,’x’,’c’,’b’,’e’,’a’,’y’,’z’,’w’};}Therearethreetextfilesf1.txt,f2.txtandf3.txt,eachcontainsthefollowingcontents:filename ThereisanotherCsourcefileex12.cwiththefollowingcontents:#include<stdio.h>voidmain(intargc,char{FILEvoidsub(FILE*);inti=1;if((fp=fopen(argv[i++],“r”))==NULL){printf(“Cannotopenfile!\n”);}else}}voidsub(FILE{char}Aftercompilingandlinking,theexecutableprogramex12.execanbeobtained.RunthecommandlineundertheDOSprompt:ex12f1.txtf2.txtf3.txt,theoutputis Section4:Accordingtothespecification,completeeachprogram(2marksforeachblank,total:20marks)Thefollowingprogramchangesthepositiveintegernumberfromindecimaltoinhexadecimal.Fillintheblankstocompletetheprogram.#include<stdio.h>#include<string.h>voidmain(){inta,i;chars[20];voidc10_16(char*,int);printf(“Inputa:”);for(i=_(1)_;i>=0;i--)printf(“%c”,*(s+i));}c10_16(char*p,int{intj;{if(_(2)_)*p=j+’0’;else*p=j-10+’A’;_(3)}}Thefollowingprogramwillconstructalinkednodessequencewhichstorestheeverycharcterofaninputcharactersline(forexample:a,b,c,…,x,y,z)toeachnodeofthelistinreverseorder.Thatis,thecharacterinputatfirstistobestoredintothetailnodeofthechainlist(asshowninthefollowingfigure),andtobeoutputinreverseorderofinputcharacters.Thenfreeallthenodes.Fillintheblankstocompletetheprogram.ZYa…ZYa#include#definegetnode(type) _(4)_malloc(sizeof(type))voidmain(){struct{charstructnodecharc; (5){p=getnode(structnode);}{ (6) }}Thereisatextfile,whichcontainsanumber(lessthan100)ofpositivedecimalintegers一100个的十进制正整数).Writeacommand-lineprogramprog.ctoreadinthesenumbers,counttheaveragevalueofallevennumbers(偶数),andfindoutthenumber(s)whichsumofalldigitsofeachnumber(各位数字之和)isgreaterthan10,andstoretheseresultsaboveintotheothertextfile.Requirements:taketheinputandoutputfilenamesascommand-lineparameters.Iftheoutputfilenameisomited(省略),thedefaultoutputwillbethestandardterminal.Fillintheblanks.ForThecommand-lineproginfile.txtTheinputtextfileinfile.txtcontainsthefollo
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024年餐饮供货合同协议书范本
- 合同签订即生效 股权变更避风险
- 组织架构及岗位职责
- 指定汽车维修服务协议
- 年度项目可行性研究报告购买合同
- 劳动合同书【乡镇企业】
- 园林苗木购销合同范本
- 场地游戏安全协议书经典版
- 2024年个人劳务协议书
- 2024股权转让合同协议书范本
- 试乘试驾管理规定
- 产品物料变更申请单
- 天然气管道应急施工方案完整
- 结构设计原理(第四版)叶见曙第1-9章课后习题答案-已按新版更新
- 优秀工作总结范文:阀门专业技术工作总结
- 按键外观及可靠性测试检验标准
- 安防监控系统室外施工安装规范标准
- 胸痛鉴别诊断
- 元明粉比重表
- 房地产项目投资成本测算参考表
- 提高护士对抢救药品知晓率PDCA案例精编版
评论
0/150
提交评论