资源描述:
《模拟上机试题库》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、·试卷一2改错题2填空题2编程题3试卷二5改错题5填空题5编程题6试卷三7改错题7填空题8编程题8试卷四9改错题9填空题10编程题10试卷五11改错题11填空题12编程题12试卷六14改错题14填空题14编程题15试卷七16改错题16填空题16编程题17试卷八18改错题18填空题19编程题19试卷九21改错题21填空题21编程题22····试卷一改错题#includevoidmain(){intx,n;scanf("%d",&x);n=1;/*$ERROR1$*/if(x<=0
2、
3、x>=10000)printf("DataError
4、!");else{if(x<=10)/*$ERROR2$*/n=1;elseif(x<100)n=2;elseif(x<1000)n=3;n=4;/*$ERROR3$*/}printf("n=%d",n);}参考答案:ERROR1:n=0;ERROR2:if(x<10);ERROR3:elsen=4;其他参考答案略。填空题#includevoidmain(){inti,max1,max2,a[10];for(i=0;i<10;i++)scanf("%d",___);/*$BLANK1$*/max1=max2=___;/*$B
5、LANK2$*/····for(i=1;i<10;i++)if(max1PRINT(floatf){FILE*out;if((out=fopen("C:\24000101\RESULT.
6、TXT","w+"))!=NULL)fprintf(out,"s=%f",f);fclose(out);}voidmain(){PRINT(s);}参考答案1:#includePRINT(floatf){FILE*out;if((out=fopen("result.txt","w+"))!=NULL)fprintf(out,"s=%f",f);····fclose(out);}voidmain(){inti,j;doubles=0,s1;for(i=1;i<=10;i++){s1=1;for(j=1;j<=i;j++)s1=s1*j
7、/(2*j+1);if(i%2)s+=s1;elses-=s1;}printf("s=%f",s);PRINT(s);}参考答案2:#includePRINT(floatf){FILE*out;if((out=fopen("result.txt","w+"))!=NULL)fprintf(out,"s=%f",f);fclose(out);}voidmain(){inti;doubles=0,s1=1;for(i=1;i<=10;i++){s1=s1*i/(2*i+1);if(i%2)s+=s1;elses-=s1;}print
8、f("s=%f",s);PRINT(s);}运行结果:····s=0.239569试卷二改错题#include#include#defineEPS0.00006voidmain(){longi;intsing;doubles,t;i=1;s=1;/*$ERROR1$*/sing=1;t=1;while(fabs(t)9、;ERROR2:while(fabs(t)>=EPS)ERROR3:i=i+2;其他参考答案略。填空题#includevoidmain(){inti,a1,a2,s;___/*$BLANK1$*/for(i=1;i___100;i++)/*$BLANK2$*/{a1=i%10;····a2=i/10;if(i%3==0)if((a1==5)___(a2==5))/*$BLANK3$*/s+=i;}printf("%d",s);}参考答案:BLANK1:s=0;BLANK2:10、
11、其它参考答案略。编程题#includ
12、ePRINT(ints){FILE*out;if((out=fopen("C:\2400