2011计算机二级c语言填空题100套题库

上传人:j****9 文档编号:45417115 上传时间:2018-06-16 格式:DOC 页数:70 大小:51.97KB
返回 下载 相关 举报
2011计算机二级c语言填空题100套题库_第1页
第1页 / 共70页
2011计算机二级c语言填空题100套题库_第2页
第2页 / 共70页
2011计算机二级c语言填空题100套题库_第3页
第3页 / 共70页
2011计算机二级c语言填空题100套题库_第4页
第4页 / 共70页
2011计算机二级c语言填空题100套题库_第5页
第5页 / 共70页
点击查看更多>>
资源描述

《2011计算机二级c语言填空题100套题库》由会员分享,可在线阅读,更多相关《2011计算机二级c语言填空题100套题库(70页珍藏版)》请在金锄头文库上搜索。

1、1.程序填空题 在主函数中从键盘输入若干个数放入数组 a 中,用 0 结束输入但不计入数组。下列给定程 序中,函数 fun 的功能是:输出数组元素中小于平均值的元素。 例如,数组中元素的值依次为 34、54、675、456、453、121,则程序的运行结果为 34、54、121。 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 注意:不得增行或删行,也不得更改程序的结构! #include #include void fun(_1_,int n) double count=0.0;double average=0.0;int i=0;for(i=0;i#define N

2、 4 void fun(int(*a)N,int *b) int I,j;for(i=0; i #define N 5 typedef struct student long sno;char name10;float score3; STU; void fun(char *filename, long sno) FILE *fp;STU n; int i;fp=fopen(filename,“rb+“); /*found*/while(!feof(fp)fread( /*found*/if(n.sno=sno) break;if(!feof(fp)for(i=0;i2)的素数的个数,素数的个

3、 数作为函数值返回。例如,输入 x=20,结果:2,3,5,7,11,13,17,19。 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 注意:不得增行或删行,也不得更改程序的结构! #include int fun(int x) int i,j,count=0;printf(“nThe prime number between 2 to %dn“,x);for(i=2;i=i)count+;printf(count%15 ? “%5d“ : “n%5d“,i);return count; main() int x=20,result;result=fun(x);pri

4、ntf(“nThe number of prime is : %dn“,result); 5.程序填空题给定程序中,函数 fun 的功能是:计算下式前 n 项的和作为函数值返回: S=1*3/2*2+3*5/4*4+5*7/6*6+(2n-1)*(2n+2)/ (2n)*(2n)例如:当行参 n 的值为 10 时,函数返回 9.612558。 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 注意:部分源程序已给出。不得增行或删行,也不得更改程序的结构! #include double fun(int n) int i; double s,t; /*found*/s=0;

5、 /*found*/for(i=1;i0): “); scanf(“%d“,printf(“The result is: %fn“,fun(n); 6.程序填空题 给定程序中,函数 fun 的功能是:将形参 s 所指字符串中的所有字母字符顺序前移,其他 字符顺序后移,处理后新字符串的首地址作为函数值返回。 例如,s 所指字符串为:asd123fgh543df,处理后新字符串为:asdfghdf12543。 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 注意:不得增行或删行,也不得更改程序的结构! #include #include #include char *fun

6、(char *s) int i,j,k,n;char *p,*t;n=strlen(s)+1;t=(char*)malloc(n*sizeof(char);p=(char*)malloc(n*sizeof(char);j=0;k=0;for(i=0;i=a)char name10;float score3; ; void fun(struct student a) struct student b; int i; /*found*/b=a;b.sno=10002; /*found*/strcpy(b.name,“LiSi“);printf(“The data after modified:n“

7、);printf(“No:%ld Name:%sn Scores: “,b.sno,b.name);for(i=0;i unsigned long fun(unsigned long n) unsigned long x=0; int t;while(n)t=n%10; /*found*/if(t%2=0) /*found*/x=x*10+t; /*found*/n=n/10;return x; main() unsigned long n=-1;while(n99999999|n #define N 5 typedef struct student long sno;char name10;

8、float score3; STU; void fun(char *filename) FILE *fp; int i,j;STU sN,t; /*found*/fp=fopen(filename,“rb“);fread(s,sizeof(STU),N,fp);fclose(fp);for(i=0;i=sj.sno)t=si;si=sj;sj=t;fp=fopen(filename,“wb“); /*found*/fwrite(s,sizeof(STU),N,fp);fclose(fp); 11.程序填空题 给定程序中,函数 fun 的功能是:利用指针数组对形参 ss 所指字符串数组中的字符串

9、按由 长到短的顺序排序,并输出排序结果。Ss 所指字符串数组中共有 N 个字符串,且串长小于 M。 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 #include #include #define N 5 #define M 8 void fun(char (*ss)M) char *psN,*tp; int i,j,k;for(i=0;i #include #define N 5 typedef struct node int data;struct node*next; NODE; /*found*/struct node *fun(NODE *h) NODE *

10、p,*q,*r;p=h;if(p=NULL) return NULL;q=p-next;p-next=NULL; /*found*/while(q != 0)r=q-next;q-next=p;p=q; /*found*/q=r;return p;13.程序填空题 给定程序中,函数 fun 的功能是:将形参 s 所指字符串中的所有数字字符顺序前移,其他 字符顺序后移,处理后新字符串的首地址作为函数值返回。 例如,s 所指字符串为:asd123fgh5#43df,处理后新字符串为:12543asdfgh#df。 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 #inclu

11、de char *fun(char *s) int i,j,k,n; char *p,*t;n=strlen(s)+1;t=(char*)malloc(n*sizeof(char);p=(char*)malloc(n*sizeof(char);j=0; k=0;for(i=0;i #include typedef struct s int data;struct s *next; NODE; void fun(int n,char *filename) NODE *h,*p,*s ;FILE *f;int i;h=p=(NODE *)malloc(sizeof(NODE);h-data=0;f

12、or(i=1;idata=i;p-next=s;p=p-next;p-next=NULL;if(f=fopen(filename,“w“)=NULL)printf(“Can not open file.dat!“);exit(0);p=h;fprintf(f,“THE LISTn“);printf(“THE LISTn“);while(p)fprintf(f,“%3d“,p-data);printf(“%3d“,p-data);if(p-next!=NULL)fprintf(f,“-“);printf(“-“);p=p-next;fprintf(f,“n“);printf(“n“);fclos

13、e(f);p=h;while(p)s=p;p=p-next;free(s); main() char *filename=“file.dat“;int n;printf(“nPlease input n:“);scanf(“%d“,fun(n,filename);16.程序填空题 给定程序中,函数 fun 的功能是计算下式:s=1*3/2*2+.+(2n-1)*(2n+1)/2n*2n #include double fun(double e) int i; double s,x;/*found*/s=0; i=0;x=1.0;while(xe) /*found*/i+; /*found*/x

14、=(2*i-1)*(2*i+1)/(double)(2*i)*(2*i);s=s+x;return s; main() double e=1e-6;printf(“The result is: %fn“,fun(e); 17.程序填空题 给定程序中,函数 fun 的功能是:计算 x 所指数组中 N 个数的平均值(规定所有数均为正 数) ,平均值通过形参返回主函数,将小于平均值且最接近平均值的数作为函数值返回,在 主函数中输出。 #include #define N 10 double fun(double x,double *av) int i,j; double d,s=0;for(i=0;i #include #include int fun(char *s) int sum=0;while(*s) /*found*/if(isdigit(*s) sum+=*s-0; /*found*/s+; /*found*/return sum; main() char s81; int n;printf(“nEnter a stri

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

最新文档


当前位置:首页 > 中学教育 > 初中教育

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