全国计算机二级考试c语言模拟试题

上传人:第*** 文档编号:60794440 上传时间:2018-11-18 格式:PDF 页数:67 大小:2.69MB
返回 下载 相关 举报
全国计算机二级考试c语言模拟试题_第1页
第1页 / 共67页
全国计算机二级考试c语言模拟试题_第2页
第2页 / 共67页
全国计算机二级考试c语言模拟试题_第3页
第3页 / 共67页
全国计算机二级考试c语言模拟试题_第4页
第4页 / 共67页
全国计算机二级考试c语言模拟试题_第5页
第5页 / 共67页
点击查看更多>>
资源描述

《全国计算机二级考试c语言模拟试题》由会员分享,可在线阅读,更多相关《全国计算机二级考试c语言模拟试题(67页珍藏版)》请在金锄头文库上搜索。

1、1 1 1套套每一套题目都是按照每一套题目都是按照“ “填空题填空题-改错题改错题-编程题编程题” ”顺序排列顺序排列, ,填空题上面带有两填空题上面带有两 个划线的是人工做题时候多余划线,不要理睬!个划线的是人工做题时候多余划线,不要理睬! #include #include #defineN10 double fun(double*x) inti, j;doubleav, yN; av=0; /*found*/ for(i=0; i void fun ( char*s,intnum5 ) intk, i=5; for ( k = 0; k= 0) numi+; main( ) chars1

2、81;intnum15, i; printf( “nPlease enter a string: “ );gets( s1 ); fun ( s1, num1 ); for ( i=0; i 3 #defineM4 #defineN5 intfun ( int aMN ) i intnttot=0,i,j;tot=0,i,j; for(i=0;i #defineN4 /*found*/ void fun(int_tNtN_ , intn) inti,s; /*found*/ for(i=0; i i #defineN10 /*found*/ intint fun(inta, intm ) in

3、tlow=0,high=N-1,mid; while(low amid) low=mid+1; elsereturn(mid); return(-1); main() inti,aN=-3,4,7,9,13,45,67,89,100,180 ,k,m; printf(“a 数组中的数据如下:“); for(i=0;i=0) printf(“m=%d,index=%dn“,m,k); elseprintf(“Not be found!n“); 编程题编程题 6 #include voidfun( char *a, char *p ) c charhar *q=a;*q=a; intint j=0

4、;j=0; while(*qstructaa*next; NODE; intfun(NODE*h) intsum = 0 ; NODE*p; /*found*/ p=hp=h-next-next; ; while(p) if(p-data%2=0) sum +=p-data; /*found*/ p=p=p p-next;-next; returnsum; NODE*creatlink(intn) NODE*h, *p, *s; inti; h=p=(NODE *)malloc(sizeof(NODE); for(i=1; idata=rand()%16; s-next=p-next; p-n

5、ext=s; p=p-next; 8 p-next=NULL; returnh; outlink(NODE*h, FILE*pf) NODE *p; p = h-next; fprintf(pf ,“nnTHELIST :nnHEAD “ ); while(p) fprintf(pf ,“-%d “,p-data ); p=p-next; fprintf (pf,“n“); outresult(ints, FILE *pf) fprintf(pf,“nThe sum of even numbers:%dn“,s); main() NODE*head;inteven; head=creatlin

6、k(12); head-data=9000; outlink(head , stdout); even=fun(head); printf(“nTheresult:n“); outresult(even, stdout); 编程题编程题 #include #include #defineN80 int fun(char *str) i intnt i,ji,j = = strlen(str);strlen(str); for(i=0;i #include #defineN6 typedef struct node intdata; struct node*next; NODE; void fu

7、n(NODE*h) NODE*p, *q;intt; p = h; while (p) /*found*/ q = _p-nextp-next_ ; /*found*/ while (_ _q q _ _) 10 if (p-data q-data) t = p-data;p-data = q-data;q-data = t; q = q-next; /*found*/ p = _ p-nextp-next _ _ ; NODE *creatlist(inta) NODE*h,*p,*q;inti; h=NULL; for(i=0; idata=ai; q-next = NULL; if (h

8、 = NULL)h = p = q; elsep-next = q;p = q; returnh; void outlist(NODE*h) NODE*p; p=h; if (p=NULL)printf(“The list is NULL!n“); else printf(“nHead“); do printf(“-%d“, p-data); p=p-next; while(p!=NULL); printf(“-Endn“); main() NODE*head; intaN= 0, 10, 4, 2, 8, 6 ; head=creatlist(a); printf(“nThe origina

9、l list:n“); outlist(head); fun(head); printf(“nThe list after inverting :n“); outlist(head); 改错题改错题 11 #include #include voidfun (char*s) /*found*/ while(*s*s) if(*s=A i,j=0,bN; for(i=p+1;i #defineN5 typedef structstudent longsno; charname10; floatscore3; 13 STU; void fun(char*filename, STUn) FILE*f

10、p; /*found*/ fp = fopen(_fpfp_ _, “rb+“); /*found*/ fseek(_fpfp_, -(long)sizeof(STU), SEEK_END); /*found*/ fwrite( fclose(fp); main() STUtN= 10001,“MaChao“, 91, 92, 77, 10002,“CaoKai“, 75, 60, 88, 10003,“LiSi“, 85, 70, 78,10004,“FangFang“, 90, 82, 87, 10005,“ZhangSan“, 95, 80, 88; STUn=10006,“ZhaoSi

11、“, 55, 70, 68, ssN; inti,j;FILE*fp; fp = fopen(“student.dat“, “wb“); fwrite(t, sizeof(STU), N, fp); fclose(fp); fp = fopen(“student.dat“, “rb“); fread(ss, sizeof(STU), N, fp); fclose(fp); printf(“nThe original data :nn“); for (j=0; j #include typedefstructaa intdata; structaa*next; NODE; NODE *Creat

12、link(intn, intm) NODE*h=NULL, *p, *s; inti; /*found*/*found*/ p=(NODEp=(NODE* * )malloc(sizeof(NODE);)malloc(sizeof(NODE); h=p; p-next=NULL; for(i=1; idata=rand()%m;s-next=p-next; p-next=s;p=p-next; /*found*/ returnreturnh h; ; outlink(NODE*h) NODE*p; p=h-next; printf(“nnTHELIST :nnHEAD “); while(p)

13、 printf(“-%d “,p-data); p=p-next; printf(“n“); main() NODE*head; head=Creatlink(8,22); outlink(head); 6 6、填空题、填空题 15 #include #defineM3 #defineN4 void fun(int(*a)N) inti=0,j,find=0,rmax,c,k; while( (i double fun ( int m ) doubley = 1.0 ; inti ; /*found*/ for(i = 2 ;i i #include int fun(int score, in

14、t m, int below) f floatloat av=0.0;av=0.0; i intnt i,j=0;i,j=0; for(i=0;iscorei)if(avscorei) 17 belowj+=scorei;belowj+=scorei; returnreturn j;j; main( ) int i, n, below9 ;void NONO (); int score9 = 10, 20, 30, 40, 50, 60, 70, 80, 90 ; n = fun(score, 9, below) ; printf( “nBelow the average score are: “ ) ; for (i = 0 ; i #include #defineN10 double fun(double*x) inti, j;doubleav, yN; 18 av=0; /*found*/ for(i=0; i void fun ( char*s,intnum5 ) intk, i=5; for ( k = 0; k= 0)

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 中学教育 > 教学课件 > 高中课件

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号