=10000)printf("DataError!n");else{if"> =10000)printf("DataError!n");else{if" />
欢迎来到天天文库
浏览记录
ID:50383577
大小:83.50 KB
页数:22页
时间:2020-03-05
《模拟上机试题库.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、试卷一改错题#includevoidmain(){intx,n;scanf("%d",&x);n=1;/*$ERROR1$*/if(x<=0
2、
3、x>=10000)printf("DataError!");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;其他参考答案略。填空题#in
4、cludevoidmain(){22inti,max1,max2,a[10];for(i=0;i<10;i++)scanf("%d",___);/*$BLANK1$*/max1=max2=___;/*$BLANK2$*/for(i=1;i<10;i++)if(max15、a[0]或*(a+0)BLANK3:max1其它参考答案略。编程题#includePRINT(floatf){FILE*out;if((out=fopen("C:\24000101\RESULT.TXT","w+"))!=NULL)fprintf(out,"s=%f",f);fclose(out);}voidmain(){PRINT(s);}参考答案1:#includePRINT(floatf)22{FILE*out;if((out=fopen("result.txt","w+"))!=NULL)fprin6、tf(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/(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",7、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;}printf("s=%f",s);22PRINT(s);}运行结果:s=0.239569试卷二改错题#include#include#defineEPS0.00006voidmain(){longi;intsing;doubles,t;i=1;s=1;/*$ERROR1$*/sing=1;t=1;wh8、ile(fabs(t)=EPS)ERROR3:i=i+2;其他参考答案略。填空题#includevoidmain(){inti,a1,a2,s;22___/*$BLANK1$*/for(i=1;i___100;i++)/*$BLANK2$*/{a1=i%10;a2=i/10;if(i%3=9、=0)if((a1==5)___(a2==5))/*$BLANK3$*/s+=i;}printf("%d",s);}参考答案:BLANK1:s=0;BLANK2:10、11、其它参考答案略。编程题#includePRINT(ints){FILE*out;if((out=fopen("C:\24000102\RESULT.TXT","w+"))!=NULL)fprintf(out,"s=%d",s);fclose(out);}voidmain(){PRINT(s);}参考答案:#includePR12、INT(ints){FILE*out;if((out=fopen("result.txt","w+"))!=NULL)fprintf(o
5、a[0]或*(a+0)BLANK3:max1其它参考答案略。编程题#includePRINT(floatf){FILE*out;if((out=fopen("C:\24000101\RESULT.TXT","w+"))!=NULL)fprintf(out,"s=%f",f);fclose(out);}voidmain(){PRINT(s);}参考答案1:#includePRINT(floatf)22{FILE*out;if((out=fopen("result.txt","w+"))!=NULL)fprin
6、tf(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/(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",
7、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;}printf("s=%f",s);22PRINT(s);}运行结果:s=0.239569试卷二改错题#include#include#defineEPS0.00006voidmain(){longi;intsing;doubles,t;i=1;s=1;/*$ERROR1$*/sing=1;t=1;wh
8、ile(fabs(t)=EPS)ERROR3:i=i+2;其他参考答案略。填空题#includevoidmain(){inti,a1,a2,s;22___/*$BLANK1$*/for(i=1;i___100;i++)/*$BLANK2$*/{a1=i%10;a2=i/10;if(i%3=
9、=0)if((a1==5)___(a2==5))/*$BLANK3$*/s+=i;}printf("%d",s);}参考答案:BLANK1:s=0;BLANK2:10、11、其它参考答案略。编程题#includePRINT(ints){FILE*out;if((out=fopen("C:\24000102\RESULT.TXT","w+"))!=NULL)fprintf(out,"s=%d",s);fclose(out);}voidmain(){PRINT(s);}参考答案:#includePR12、INT(ints){FILE*out;if((out=fopen("result.txt","w+"))!=NULL)fprintf(o
10、
11、其它参考答案略。编程题#includePRINT(ints){FILE*out;if((out=fopen("C:\24000102\RESULT.TXT","w+"))!=NULL)fprintf(out,"s=%d",s);fclose(out);}voidmain(){PRINT(s);}参考答案:#includePR
12、INT(ints){FILE*out;if((out=fopen("result.txt","w+"))!=NULL)fprintf(o
此文档下载收益归作者所有