2013省考上机模拟两个叠加-赵功建.doc_第1页
2013省考上机模拟两个叠加-赵功建.doc_第2页
2013省考上机模拟两个叠加-赵功建.doc_第3页
2013省考上机模拟两个叠加-赵功建.doc_第4页
2013省考上机模拟两个叠加-赵功建.doc_第5页
已阅读5页,还剩13页未读 继续免费阅读

下载本文档

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

文档简介

模拟01#include void main() int i,j,flag,n; n=0; i=7; while(n=10) /*$ERROR1$*/ flag=0; for(j=2;j=0) /*$ERROR3$*/ n=n+1; printf(%dn,i); i=i+10; $ERROR1$:while(n=10)$ERROR2$:if(i%j=0)$ERROR3$:if(flag=0)#include void main() int score; printf(Enter your score:); scanf(%d,_); /*$BLANK1$*/ printf(grade is:); switch(_) /*$BLANK2$*/ case 10: case 9:printf(An);break; case 8:printf(Bn);break; case 7:printf(Cn);break; case 6:printf(Dn);break; _:printf(En); /*$BLANK3$*/ $BLANK1$:&score$BLANK2$:score/10$BLANK3$:default#include #include void PRINT(double s) FILE *out; printf(s=%.2fn,s); if(out=fopen(C:24000101RESULT.DAT,w+)!=NULL) fprintf(out,s=%.2f,s); fclose(out);void main() double s=0; int i; for(i=300;i=2013;i+)if(i%9=0|i%13=0) s=s+sqrt(i); PRINT(s);模拟02#include void main() int a; scanf(%d,a); /*$ERROR1$*/ if(a100) printf(Data Error!n); else else if(a=90) printf(An); /*$ERROR2$*/ else if(a=80) printf(Bn); else if(a=70) printf(Cn); else if(a=60) printf(Dn); printf(En); /*$ERROR3$*/ $ERROR1$:scanf(%d,&a);$ERROR2$:if(a=90) printf(An);(去掉开始的else)$ERROR3$:else printf(En);(行首添加else)#include void main()long s, t;printf(nPlease enter s:); scanf(%ld,&s);t = s%10; s/= 10;while(_) /*$BLANK1$*/ t =_+ s%10;/*$BLANK2$*/s/= 10;printf(The result is: _n, t); /*$BLANK3$*/$BLANK1$:s0$BLANK2$:t*10$BLANK3$:%ld#include void PRINT(int a,int b,int c) FILE *out; printf(big=%d,mid=%d,small=%dn,a,b,c); if(out=fopen(C:24000102RESULT.DAT,w+)!=NULL) fprintf(out,big=%dp,mid=%dp,small=%dp,a,b,c); fclose(out);void main() int a,b,c; for(a=1;a25;a+)for(b=1;b33;b+) for(c=5;c100;c=c+5) if(a+b+c=100&4*a+3*b+c/5=100)PRINT(a,b,c);模拟03#include void main()int i,j;int n;scanf(%d,n);/*$ERROR1$*/for (i=1;i=n;i+)for (j=1;j=n-i;j+)printf( );j=0;/*$ERROR2$*/while (j=i)printf(%-2d,i);j+;print(n)/*$ERROR3$*/$ERROR1$:scanf(%d,&n);$ERROR2$:j=1;$ERROR3$:printf(n);#include void main() int i,a,b,c,n; n=_; /*$BLANK1$*/ for(i=101;i=999;i+) a=i%10; b=i/10%10; c=_; /*$BLANK2$*/ if(a*a*a+b*b*b+c*c*c=i) printf(%6d,i); _; /*$BLANK3$*/ printf(nn=%dn,n);$BLANK1$:0$BLANK2$:i/100$BLANK3$:n+#include void PRINT(long s) FILE *out; printf(s=%ldn,s); if(out=fopen(C:24000103RESULT.DAT,w+)!=NULL) fprintf(out,s=%ld,s); fclose(out);void main() long s=0;int i,j,k,t;for(i=0;i=3;i+) for(j=0;j=3;j+) for(k=0;k=3;k+) t=i*100+j*10+k; if(t%2=1) s=s+t; PRINT(s);模拟04输出一维数组中的最大元素及其下标值。#include void main() int a10=-3,1,-5,4,9,0,-8,7,-6,2; int i,addr; addr=1; /*$ERROR1$*/ i=1; while(i=10) /*$ERROR2$*/ if(aaddrai) i=addr; /*$ERROR3$*/ i+; printf(max=%d,address=%dn,aaddr,addr);$ERROR1$:addr=0;$ERROR2$:while(i10)$ERROR3$:addr=i;#include #include void main()char s100;int left,right,middle,lenth;printf(Please input a string:);gets(s);lenth = strlen(s);left = _; /*$BLANK1$*/middle = lenth/2;while(leftmiddle)right = lenth-1-left;if(sleft _ sright) /*$BLANK2$*/ left+; elsebreak;if(left _ middle) /*$BLANK3$*/printf(Non);elseprintf(Yesn); $BLANK1$:left=0;$BLANK2$:if(sleft = sright)$BLANK3$:if(leftmiddle)#include void PRINT(double s) FILE *out; printf(s=%.2fn,s); if(out=fopen(C:24000104RESULT.DAT,w+)!=NULL) fprintf(out,s=%.2f,s); fclose(out);void main() double s=100,h=100; int i; for(i=1;i8;i+) h=h/2; s=s+2*h; PRINT(s);模拟05#include void main()char s81;int num5,i,k,j;printf(Please enter a string:);gets(s);i=5;for (k=0;k=0) numi+;j-;/*$ERROR3$*/for (i=0;i5;i+)printf(%4d,numi);printf(n);$ERROR1$:numk=0;$ERROR2$:switch(sj)$ERROR3$:j+;#include void main() int i,j,row,col; int a34=3,5,1,8,6,4,11,7,9,3,10,2; row=col=0; for(i=0;i_;i+) /*$BLANK1$*/ for(j=0;j4;j+) if(arowcol _ ) /*$BLANK2$*/ row=i; col=j; printf(max=%d,row=%d,col=%dn,_,row,col); /*$BLANK3$*/$BLANK1$:3$BLANK2$:aij$BLANK3$:arowcol#include void PRINT(int n) FILE *out; printf(n=%dn,n); if(out=fopen(C:24000105RESULT.DAT,w+)!=NULL) fprintf(out,n=%d,n); fclose(out);void main()int n=0,s=10000; while(s=1000) n+; s=s-n; PRINT(n);模拟06#include struct student int num; char name12; int score;void main() student stud6= 1001,Pan Dong,48, /*$ERROR1$*/ 1002,Zhao Hua,62, 1003,Hu Litai,93, 1004,Zhang Li,85, 1005,Liu Ming,58, 1006,Xin Peng,37; int i,n=0; printf(numtnamettscoren); i=1;/*$ERROR2$*/ while(i6) if(studi.score60) printf(%dt%st%dn,studi.num,,studi.score); n-; /*$ERROR3$*/ i+; printf(n=%dn,n);$ERROR1$:struct student stud6= 1001,Pan Dong,48,$ERROR2$:i=0;$ERROR3$:n+;#include void main() int i; float a9,max,min,ave; printf(Input array:n); for(i=0;i9;i+) scanf(%f,_); /*$BLANK1$*/ max=min=ave=_; /*$BLANK2$*/ for(i=1;i9;i+) ave+=ai; if(maxai) _; /*$BLANK3$*/ ave=(ave-max-min)/7; printf(Mark=%.3fn,ave);$BLANK1$:&ai$BLANK2$:a0$BLANK3$:min=ai#include void PRINT(int count) FILE *out; printf(count=%dn,count); if(out=fopen(C:24000106RESULT.DAT,w+)!=NULL) fprintf(out,count=%d,count); fclose(out);void main()int count=0; int a,b,c; for(a=1;a100;a+) for(b=1;b20;b+) for(c=1;c10;c+) if(a+5*b+10*c=100) count+; PRINT(count);模拟07#include void main() char s80; int i; getc(s); /*$ERROR1$*/ for(i=0; si!=0; i+) if(si=z) /*$ERROR2$*/ si=a; else if(si=a&si=y) si=si+1; printf(%cn,s); /*$ERROR3$*/$ERROR1$:gets(s);$ERROR2$:if(si=z)$ERROR3$:printf(%sn,s);#include void main()double x,y;printf(Please input x:);scanf(%lf,_); /*$BLANK1$*/if(x_3) /*$BLANK2$*/y=8;else if(x_50) /*$BLANK3$*/ y=2*(8+(x-3)*1.5);else y=8+(x-3)*1.5; printf(y=%.1fn,y);$BLANK1$:&x$BLANK2$:=#include void PRINT(double s) FILE *out; printf(s=%.5fn,s); if(out=fopen(C:24000107RESULT.DAT,w+)!=NULL) fprintf(out,s=%.5f,s); fclose(out);void main()double s=0,f; int x; for(x=-10;x=10;x+) if(x=0|x=2) f=0;else if(x0) f=1.0*(x-1)/(x-2); else f=1.0*(x+1)/(x-2);s=s+f; PRINT(s);模拟08#include double fun(int n) int i; double s; s=1.0; for(i=2;i=n;i+) s+=1.0/i; return ; /*$ERROR1$*/void main() int n; double result; printf(nplease enter 1 integer numbers:n); scanf(%d,n); /*$ERROR2$*/ result=fun(&n); /*$ERROR3$*/ printf(nthe result is %lfn,result); $ERROR1$:return s;$ERROR2$:scanf(%d,&n);$ERROR3$:result=fun(n);#include int gcd(int m,int n) int r,t; if(m0) r=m%n; m=n; n=r; return(_); /*$BLANK2$*/ void main() int m,n,result; printf(Pease input two number:n); scanf(%d%d,_); /*$BLANK3$*/ result=gcd(m,n); printf(result=%dn,result);$BLANK1$:n=t$BLANK2$:m$BLANK3$:&m,&n#include void PRINT(long s) FILE *out; printf(s=%ldn,s); if(out=fopen(C:24000108RESULT.DAT,w+)!=NULL) fprintf(out,s=%ld,s); fclose(out);void main()long s=0,t=1,i;for(i=1;i=16;i+) t=t*2; s=s+t; PRINT(s);模拟09#include long fun(int n) if(n=1) /*$ERROR1$*/ return 2; else return fun()+3; /*$ERROR2$*/void main() long m; int n; scanf(%d,n); /*$ERROR3$*/ if(n0) m=fun(n); printf(%ldn,m); $ERROR1$:if(n=1)$ERROR2$:return fun(n-1)+3;$ERROR3$:scanf(%d,&n);#includevoid main()char s80; int i,j;printf(Please input a string:);gets(_); /*$BLANK1$*/for(i=0,j=0;si!=_;i+) /*$BLANK2$*/ if(si != 32) sj+=si; sj=_; /*$BLANK3$*/puts(s);$BLANK1$:s$BLANK2$:0$BLANK3$:0#include void PRINT(double s) FILE *out; printf(s=%.5fn,s); if(out=fopen(C:24000109RESULT.DAT,w+)!=NULL) fprintf(out,s=%.5f,s); fclose(out);void main()double s=0; long i,t=0; for(i=1;i6;i+) t=t*10+8;s=s+1.0/t PRINT(s);172011年省级二级上级模拟复习模拟1二、改错将1到100间的所有素数保存在数组prime中,输出这些素数并计算它们的和(说明:每行输出10个数据,每个数据占4列)#include void main() int i,j,k,sum; int prime50; sum=1; /*$ERROR1$*/ k=0; for(i=2;i100;i+) for(j=2;ji) /*$ERROR2$*/ sum+=i; primek+=i; printf(nPrime list(1-100):); for(i=0;ik;i+) if(i%10=0) printf(n); printf(%4d,&primei); /*$ERROR3$*/ printf(nsum=%dn,sum); $1$:sum=0;$2$:if(i=j)$3$:printf(%4d,primei);三、填空将字符串str中的字符以只写方式写入到新建的文本文件out2011.txt中。#include #include #define N 81void main() int i=0; char ch; char strN=2011 C test!; _ *fp; /*$BLANK1$*/ if(fp=fopen(out2011.txt,_)=NULL) /*$BLANK2$*/ printf(Can not create the file!);exit(0); while(stri) ch=stri; fputc(ch,_);/*$BLANK3$*/ putchar(ch); i+; putchar(n); fclose(fp); BLANK1:FILEBLANK2:wBLANK3:fp四、程序设计求100-999之间的回文素数之和。(1)回文素数是一个素数,且从左向右和从右向左读是相同的,如:101,131,181是回文素数;(2)要求使用循环实现。#include void PRINT(long s) FILE *out; printf(s=%ldn,s); if(out=fopen(C:24000101RESULT.DAT,w+)!=NULL) fprintf(out,s=%ld,s); fclose(out);void main() long s=0; int a,b,i,j; for(i=100;i1000;i+) a=i/100; b=i%10; if(a=b) for(j=2;ji/2) s=s+i; PRINT(s);模拟2二、改错在屏幕上输出以下图形(说明:星号之间没有空格)#include void main() int i,j; i=1; /*$ERROR1$*/ while(i5) j=0; while(j0) j=0; while(j5-i) /*$ERROR2$*/ printf(*); j+; printf(n); i+ /*$ERROR3$*/ $1$:i=0;$2$:while(j=5-i)$3$:i-;三、填空输出以下图形(说明:字符之间没有空格)AAABAAAAABBBAAABBBBBABBBBBBBAABBBAAAAABAAA#include #include void main() int i,j; for(i=-3;i=_;i+) /*$BLANK1$*/ j=1; while(j=abs(i) printf(A);j+; j=1; while(j_7-2*abs(i) /*$BLANK2$*/ printf(B);j+; j=1; while(j=abs(i) printf(A); _; /*$BLANK3$*/ printf(n); BLANK1:3BLANK2:=BLANK3:j+四、程序设计三色球问题若一个口袋中放有12个球,其中有3个红色的,3个白色的和6个黑色的,从中任取8个球,求共有多少种不同的颜色搭配。如:2个白色球和6个黑色球;1个红色球、3个白色球和4个黑色球;#include void PRINT(int n) FILE *out; printf(count=%dn,n); if(out=fopen(C:24000102RESULT.DAT,w+)!=NULL) fprintf(out,count=%dp,n); fclose(out);void main()int n; int a,b,c; for(a=0;a=3;a+) for(b=0;b=3;b+) for(c=0;c=6;c+) if(a+b+c=8) n+; PRINT(n);模拟3二、改错计算9到999之间个位数是9并且能被9整除的所有数之和。#include void main() int i,sum; sum=1; /*$ERROR1$*/ for(i=9;i=999;i+) if(i%9=0) if(i%10=9) sum=i; /*$ERROR2$*/ print(%dn,sum); /*$ERROR3$*/$1$:sum=0;$2$:sum=sum+i;$3$:printf(%dn,sum);三、填空输出所有“水仙花数”,并输出“水仙花数”的个数。所谓“水仙花数”是指一个三位数,其各位数字的立方和等于该数本身。例如153是一个“水仙花数”,因为153=1*1*1+5*5*5+3*3*3。#include void main() int i,a,b,c,n; n=_; /*$BLANK1$*/ for(i=101;i=999;i+) a=i%10; b=i/10%10; c=_; /*$BLANK2$*/ if(a*a*a+b*b*b+c*c*c=i) printf(%6d,i); _; /*$BLANK3$*/ printf(nn=%dn,n);BLANK1:0BLANK2:i/100BLANK3:n+或+n四、程序设计计算1-1000之间能被3或7整除的所有自然数的倒数之和。说明:(1)结果保留5位小数;(2)要求使用循环实现。#include void PRINT(double s) FILE *out; printf(s=%.5fn,s); if(out=fopen(C:24000103RESULT.DAT,w+)!=NULL) fprintf(out,s=%.5f,s); fclose(out);void main() double s=0; int i; for(i=1;i=1000;i+) if(i%3=0|i%7=0) s+=1.0/i; PRINT(s);模拟4二、改错在屏幕上输出以下图形(字符之间没有空格)1234523451345124512351234#include void main() char a6=12345,temp; int i,k; for(i=1;i=5;i+) printf(%cn,a); /*$ERROR1$*/ temp=a0; for(k=0;k4;k+) ak+1=ak; /*$ERROR2$*/ a4=a0; /*$ERROR3$*/ $1$:printf(%sn,a);$2$:ak=ak+1;$3$:a4=temp;三、填空假设银行整存整取存款不同的期限的月息利率分别为:0.315% 期限一年0.330% 期限二年0.345% 期限三年0.375% 期限五年0.420% 期限八年或八年以上输入存钱的本金和整存整取得期限,求到期时能从银行得到的利息与本金的合计。#include #include void main( ) int year; double money,rate,interest,total; printf(Input money and year :n); scanf(%lf%d,&money, &year); if(year1时F(n)=(F(n-1)+10/F(n-1)/2求该数列第5项即F(5)的值。说明:(1)结果保留五位小数;(2)要求使用循环实现。#include void PRINT(double f) FILE *out; printf(F(5)=%.5fn,f); if(out=fopen(C:24000104RESULT.DAT,w+)!=NULL) fprintf(out,F(5)=%.5f,f); fclose(out);void main() double f=5; int i; for(i=2;i=5;i+) f=(f+10/f)/2; PRINT(f);模拟5二、改错把字符串中所有数字字符按以下规律改写(1)0,1,2,3,4,5,6,7,8改写成1,2,3,4,5,6,7,8,9(2)9改成0(3)其他字符保持不变#include #include void main() char s80; int i; getc(s); /*$ERROR1$*/ for(i=0; si!=0; i+) if(si=9) /*$ERROR2$*/ si=0; else if(si=0 & si=8) si=si+1; printf(%cn,s); /*$ERROR3$*/$1$:gets(s);$2$:if(si=9)$3$:printf(%sn,s);三、填空某部门有三位职工,要求输入职工的工资信息,计算每位职工的实发工资和部门实发工资总额(total)(1)描述职工工资信息的数据包括编号(num)、姓名(name)、基本工资(bwage)、奖金(bonus)、保险(ins)和实发工资(rwage);(2)实发工资=基本工资+奖金-保险(3)职工编号长度小于10位且为整数,姓名不包含空格。#include #define N 3struct employee long num; char name15; long bwage,bonus,ins,rwage;void main() _ workerN;/*$BLANK1$*/ int i; long total; total=_; /*$BLANK2$*/ printf(Please input data:n); printf(nnum name bwage bonus ins:n); for(i=0;iN;i+) scanf(%ld%s, &workeri.num, ); scanf(%ld%ld%ld, &workeri.bwage, &workeri.bonus, &workeri.ins); for(i=0;iN;i+) _=workeri.bwage +workeri.bonus -workeri.ins; /*$BLANK3$*/ total=total+workeri.rwage; printf(output:n ); printf(nnum name real wagen); for(i=0;iN;i+) printf(%-9ld %-14s %-ldn, workeri.num, , workeri.rwage); printf(ntotal wage =%ldn,total);BLANK1: struct employeeBLANK2: 0BLANK3: workeri.rwage

温馨提示

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

评论

0/150

提交评论