当前位置:高等教育资讯网  >  中国高校课件下载中心  >  大学文库  >  浏览文档

《2009年二级C语言资料》1二级C填空题题目

资源类别:文库,文档格式:DOC,文档页数:16,文件大小:453KB,团购合买
一、填空题 考试做题要求:1、在__1__处填写正确的答案,并将下划线和数字删除。 2、将题目做完之后一定要保存。3、不能删除/**********found**********/,也不能多行或少行。
点击下载完整版文档(DOC)

www.greatc.cn4月上机考试题库填空题 for(=0,j4,j++) 试做题要求:1、在1处填写正确的答案,并将下划线 printf("\nNo: % ld Name: %0-8s 和数字删除。2、将题目做完之后一定要保存。3、不能删"]sno, soname) 除/**春事 found**事**/,也不能多行或少行。 for(F0; 1 for(0; 1av) yL 3Fx[]: 不得增行或删行,也不得更改程序的结构! y]=-1; #include #include struct student i f int 1, double xINlyN name[10] for(F0; I<N; i++)(x[]rando%50; printf("%4. 0f"xD: printf("un"); printf("nThe average is: %fn", fun(x, y )); void fun(struct student a[, int n) for(F0; yI=0; 1++) printf("%5.If "y; printf("n"); 体率*本亭率布布 found布事率事事摩/ 4、给定程序中,函数fun的功能是:将a所指4×3矩阵中 事 found*事亭事事率春摩事率 第k行的元素与第0行元素交 for(F=0,<2_,i++) 例如,有下列矩阵 for(=计+1;j<n;j+) 2 率*布亭率率布 found事拿本事事事*/ t=;=毗;a=t} 若k为2,程序执行结果为: maino 7 89 f struct student s[4(( 10001, Zhang San,95, 80, 88) {10002,"Lisi",85,70,78} {10003, CasKa",75,60,88}, {10004," Fangfang",90,82,87}} 请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果 printf("lnlnThe original data nin); 注意:源程序存放在考生文件夹下的 BLANKLC中

宏为世纪教育 www.greatc.cn 4 月上机考试题库 填空题 1 一、填空题 考试做题要求:1、在__1__处填写正确的答案,并将下划线 和数字删除。 2、将题目做完之后一定要保存。3、不能删 除/**********found**********/,也不能多行或少行。 1、给定程序中,函数 fun 的功能是根据形参 i 的值返回某 个函数的值。当调用正确时, 程序输出: x1=5.000000, x2=3.000000, x1*x1+x1*x2=40.000000 请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1.C 中。 不得增行或删行,也不得更改程序的结构! #include double f1(double x) { return x*x; } double f2(double x, double y) { return x*y; } /**********found**********/ __1__ fun(int i, double x, double y) { if (i==1) /**********found**********/ return __2__(x); else /**********found**********/ return __3__(x, y); } main() { double x1=5, x2=3, r; r = fun(1, x1, x2); r += fun(2, x1, x2); printf("\nx1=%f, x2=%f, x1*x1+x1*x2=%f\n\n",x1, x2, r); } 2、程序通过定义学生结构体数组,存储了若干名学生的学 号、姓名和 3 门课的成绩。函数 fun 的功能是将存放学生数 据的结构体数组,按照姓名的字典序(从小到大)排序。 请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1.C 中。 不得增行或删行,也不得更改程序的结构! #include #include struct student { long sno; char name[10]; float score[3]; }; void fun(struct student a[], int n) { /**********found**********/ __1__ t; int i, j; /**********found**********/ for (i=0; i 0) { t = a[i]; a[i] = a[j]; a[j] = t; } } main() { struct student s[4]={{10001,"ZhangSan", 95, 80, 88}, {10002,"LiSi", 85, 70, 78}, {10003,"CaoKai", 75, 60, 88}, {10004,"FangFang", 90, 82, 87}}; int i, j; printf("\n\nThe original data :\n\n"); for (j=0; j #define N 10 double fun(double x[],double *y) { int i,j; double av; /**********found**********/ av=__1__; /**********found**********/ for(i=0; iav) y[__3__]= x[i]; y[j]=-1; return av; } main() { int i; double x[N],y[N]; for(i=0; i=0; i++) printf("%5.1f ",y[i]); printf("\n"); } 4、给定程序中,函数 fun 的功能是:将 a 所指 4×3 矩阵中 第 k 行的元素与第 0 行元素交换。 例如,有下列矩阵: 1 2 3 4 5 6 7 8 9 10 11 12 若 k 为 2,程序执行结果为: 7 8 9 4 5 6 1 2 3 10 11 12 请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1.C 中

cn4月上机考试题库填空 不得增行或删行,也不得更改程序的结构! while( strlen(s2PN ): int xM]N={{12,3},{4,5,6},{7,8,9},{10,11,12}},ij, double fun(int n) rinf("The array before moving: nn"); for(=0,i0): ) scanf("%d", &n); 规定字符串中只含9个以下数字字符 printf("nThe result is: %f\n", fun(n)) 例如,主函数中输入字符串:32486和12345,在主函} 数中输出的函数值为:44831。 请在程序的下划线处填入正确的内容并把下划线删除,7、给定程序中,函数fun的功能是:在3×4的矩阵中找 使程序得出正确的结果 在行上最大、在列上最小的那个元素,若没有符合条件的元 注意:源程序存放在考生文件夹下的 BLANK1C中 素则输出相应信息。 不得增行或删行,也不得更改程序的结构! 例如,有下列矩阵 #include #include #define n 9 程序执行结果为:fnd:a[2]2}=9 long ctod( char *s) 请在程序的下划线处填入正确的内容并把下划线删除 使程序得出正确的结果 注意:源程序存放在考生文件夹下的 BLANKL.C中 不得增行或删行,也不得更改程序的结构! 率*布布亭事布 found布事率率事春事事/ #include d=d*10+率s #define M 3 /**布亭枣事 found亭事事布摩* #define n 4 void fun(int a)IND f int F0,j, find=0, rmax, c, k; long fun( char * a, char *b) i rmax=ab[o c=0; for(F1; K<N; j++) /*率布事*本事布 found*事**/ t(rmax rmax=a0;c= find=l: k=0 sI[NI S2IN: hile(k<M & find )i i printf("Input string sl: ) gets(s1); if(kl=i&& akcl<=rmax) find= while( strlen(sIPN) i printf("Input string s2: ") gets(s2); i if(find) printf("find: a[odI[%d=%d\n, i, c, an[cD);

宏为世纪教育 www.greatc.cn 4 月上机考试题库 填空题 2 不得增行或删行,也不得更改程序的结构! #include #define N 3 #define M 4 /**********found**********/ void fun(int (*a)[N], int __1__) { int i,j,temp ; /**********found**********/ for(i = 0 ; i #include #include #define N 9 long ctod( char *s ) { long d=0; while(*s) if(isdigit( *s)) { /**********found**********/ d=d*10+*s-__1__; /**********found**********/ __2__; } return d; } long fun( char *a, char *b ) { /**********found**********/ return __3__; } main() { char s1[N],s2[N]; do { printf("Input string s1 : "); gets(s1); } while( strlen(s1)>N ); do { printf("Input string s2 : "); gets(s2); } while( strlen(s2)>N ); printf("The result is: %ld\n", fun(s1,s2) ); } 6、给定程序中,函数 fun 的功能是:计算下式前 n 项的和 作为函数值返回。 例如,当形参 n 的值为 10 时,函数返回:9.612558。 请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1.C 中。 不得增行或删行,也不得更改程序的结构! #include double fun(int n) { int i; double s, t; /**********found**********/ s=__1__; /**********found**********/ for(i=1; i0): "); scanf("%d",&n); } printf("\nThe result is: %f\n",fun(n)); } 7、给定程序中,函数 fun 的功能是:在 3×4 的矩阵中找出 在行上最大、在列上最小的那个元素,若没有符合条件的元 素则输出相应信息。 例如,有下列矩阵: 1 2 13 4 7 8 10 6 3 5 9 7 程序执行结果为:find: a[2][2]=9 请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1.C 中。 不得增行或删行,也不得更改程序的结构! #include #define M 3 #define N 4 void fun(int (*a)[N]) { int i=0,j,find=0,rmax,c,k; while( (i<M) && (!find)) { rmax=a[i][0]; c=0; for(j=1; j<N; j++) if(rmax<a[i][j]) { /**********found**********/ rmax=a[i][j]; c= __1__ ; } find=1; k=0; while(k<M && find) { /**********found**********/ if (k!=i && a[k][c]<=rmax) find= __2__ ; k++; } if(find) printf("find: a[%d][%d]=%d\n",i,c,a[i][c]);

eatc.cn4月上机考试题库填空 率布布率率 found布摩率率布摩摩率 #include struct student i if(!find) printf("not found! \ n"); lo oat score3] i int xMINI,Lj printf("Enter number for array: n"); void fun(struct student a) /**********found*** Int L, i struct stude for(=0; j #include #define N 5 #define M 10 /率事事*布 found*亭事事事事率*/ har void fun( char ss) XINIIMF"Beijing", "Shanghai", Tianj ing", Nanjing",Wuhan t 体率事事布布 found事率事事事**/ int i,f. rinf("\nThe original string\nin"); 率布事率布布 found市事事率*布事率*/ for(FO; <N; i++)puts(x[); printi("n"); ss]3;计++;} ffun(x, 7), rinf("The string witch length is less than or equal to 7: n"); maino for(F0; i<f, i++)puts(x[]), printf("un") har xNIIM "Create", Modify","Sort","skip", Delete printf("\nThe original stringinIn); 9、程序通过定义学生结构体变量,存储了学生的学号、姓 for(FO I<N; i++)puts(x[]); printf("wn); 名和3门课的成绩。函数fmn的功能是将形参a所指结构体 fun(x, 4) 变量中的数据赋给函数中的结构体变量b,并修改b中的学 printf("nThe string after deleted InIn"); 号和姓名,最后输出修改后的数据。例如:a所指变量中的 for(F0; i<N; 1++)puts(xO): printf("n"); 学号、姓名、和三门课的成绩依次是:10001、" ZhangSan"、} 则修改后输出b中的数据应为:10002、"LiSi" 95、80、88。 11、给定程序中,函数fun的功能是:把形参s所指字符串 请在程序的下划线处填入正确的内容并把下划线删除, 最右边的n个字符复制到形参t所指字符数组中,形成 使程序得出正确的结果 个新串。若s所指字符串的长度小于n,则将整个字符串复 注意:源程序存放在考生文件夹下的 BLANK1C中 制到形参t所指字符数组中 不得增行或删行,也不得更改程序的结构! 例如,形参s所指的字符串为 : abcdefgh,n的值为5

宏为世纪教育 www.greatc.cn 4 月上机考试题库 填空题 3 /**********found**********/ __3__ ; } if(!find) printf("not found!\n"); } main() { int x[M][N],i,j; printf("Enter number for array:\n"); for(i=0; i #include #define N 5 #define M 10 int fun(char (*ss)[M], int k) { int i,j=0,len; /**********found**********/ for(i=0; i #include struct student { long sno; char name[10]; float score[3]; }; void fun(struct student a) { struct student b; int i; /**********found**********/ b = __1__; b.sno = 10002; /**********found**********/ strcpy(__2__, "LiSi"); printf("\nThe data after modified :\n"); printf("\nNo: %ld Name: %s\nScores: ",b.sno, b.name); /**********found**********/ for (i=0; i #include #define N 5 #define M 10 /**********found**********/ void fun(char (*ss) __1__, int k) { int i=0 ; /**********found**********/ while(i< __2__) { /**********found**********/ ss[i][k]=__3__; i++; } } main() { char x[N][M]={"Create","Modify","Sort","skip","Delete"}; int i; printf("\nThe original string\n\n"); for(i=0;i<N;i++)puts(x[i]); printf("\n"); fun(x,4); printf("\nThe string after deleted :\n\n"); for(i=0; i<N; i++) puts(x[i]); printf("\n"); } 11、给定程序中,函数 fun 的功能是:把形参 s 所指字符串 中最右边的 n 个字符复制到形参 t 所指字符数组中,形成一 个新串。若 s 所指字符串的长度小于 n,则将整个字符串复 制到形参 t 所指字符数组中。 例如,形参 s 所指的字符串为:abcdefgh,n 的值为 5

cn4月上机考试题 程序执行后t所指字符数组中的字符串应为:degh 请在程序的下划线处填入正确的内容并把下划线删除,13、给定程序中,函数fun的功能是:找出100~999 使程序得出正确的结果。 之间(含100和999)所有整数中各位上数字之和为x( 注意:源程序存放在考生文件夹下的 BLANK1C中 为一正整数)的整数,然后输出:符合条件的整数个数作为 不得增行或删行,也不得更改程序的结构! 函数值返回 #include 例如,当x值为5时,100~999之间各位上数字之 #include 为5的整数有:104、113、122、131、140、203、212、221 #deir 230、302、311、320、401、410、500。共有15个。当x值 void fun(char *s, int n, char *t) 为27时,各位数字之和为27的整数是:999。只有1个。 请在程序的下划线处填入正确的内容并把下划线删除 使程序得出正确的结果。 /**事事率率 found事事事*/ 注意:源程序存放在考生文件夹下的 BLANKLO中 if(n>=len) strcpy(1; 不得增行或删行,也不得更改程序的结构! #include 率布事率率布布 found和 un( int x) for(rlen-n;κ0): ") scanf("%d", &x); 3 注意:源程序存放在考生文件夹下的 BLANKl.C中 printf("nThe result is: %d\", fun(x)) 不得增行或删行,也不得更改程序的结构! #include #include 14、给定程序中,函数fun的功能是:将形参s所指字符串 #include 中的数字字符转换成对应的数值,计算出这些数值的累加和 #include 作为函数值返回 例如,形参s所指的字符串为: abs 5de26jkm8,程序 Int 执行后的输出结果为:22 n=strlen(s)+l 请在程序的下划线处填入正确的内容并把下划线删除 使程序得出正确的结果 char*)malloc(n*sizeof( char) 注意:源程序存放在考生文件夹下的 BLANKLC中 」=0,k=0, 不得增行或删行,也不得更改程序的结构! for(F=0,i i if( isdigit(sD)i #include /**布亭本事 found*率本亭事* tk}=[k++;} /率布布事率* found事事**率*/ 率*布亭率布 found布事拿本事事事*/ if( isdigit(°s)) for(=0,2_;计++)p+t /率事事事事* found事*率事率*/ return 3 /率布布事率* found事事**布率*/ printf("Please input: ") scanf("%s"S) i char s[81]: int n; printf("n The result is: %s\n",fun(s) printf("nEnter a string: nn"): gets(s)

宏为世纪教育 www.greatc.cn 4 月上机考试题库 填空题 4 程序执行后 t 所指字符数组中的字符串应为:defgh。 请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1.C 中。 不得增行或删行,也不得更改程序的结构! #include #include #define N 80 void fun(char *s, int n, char *t) { int len,i,j=0; len=strlen(s); /**********found**********/ if(n>=len) strcpy(__1__); else { /**********found**********/ for(i=len-n; i #include #include #include 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 fun(int x) { int n, s1, s2, s3, t; n=0; t=100; /**********found**********/ while(t0): "); scanf("%d",&x); } printf("\nThe result is: %d\n",fun(x)); } 14、给定程序中,函数 fun 的功能是:将形参 s 所指字符串 中的数字字符转换成对应的数值,计算出这些数值的累加和 作为函数值返回。 ?例如,形参 s 所指的字符串为:abs5def126jkm8,程序 执行后的输出结果为:22。 请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1.C 中。 不得增行或删行,也不得更改程序的结构! #include #include #include int fun(char *s) { int sum=0; while(*s) { /**********found**********/ if( isdigit(*s) ) sum+= *s- __1__ ; /**********found**********/ __2__; } /**********found**********/ return __3__ ; } main() { char s[81]; int n; printf("\nEnter a string:\n\n"); gets(s); n=fun(s);

www.greatc.cn4月上机考试题库填空题 printf("nThe result is: %d\nin" n); outlist(head fun(head) printf(" The list after sorting: n"); 15、给定程序中函数fun的功能是将带头节点的单向链表结 outlist(head) 点数据域中的数据从小到大排序。即若原链表结点数据域从} 头至尾的数据为:10、4、2、8、6,排序后链表结点数据域 从头至尾的数据为:2、4、6、8、10 16、程序通过定义学生结构体变量,存储了学生的学号、姓 请在程序的下划线处填入正确的内容并把下划线删除,名和3门课的成绩。函数fun的功能是将形参a所指结构体 使程序得出正确的结果 变量s中的数据进行修改,并把a中地址作为函数值返回主函 注意:源程序存放在考生文件夹下的 BLANK1C中 数,在主函数中输出修改后的数据 不得增行或删行,也不得更改程序的结构 例如:a所指变量s中的学号、姓名、和三门课的成绩 #include 依次是:10001、" ZhangSan"、95、80、88,修改后输出t #include 中的数据应为:10002、"Lisi"、96、81、89 #definen 6 请在程序的下划线处填入正确的内容并把下划线删除 typedef struct node i 使程序得出正确的结果 int data 主意:源程序存放在考生文件夹下的 BLANKLO中 struct node 'next; 不得增行或删行,也不得更改程序的结构! A NODE; void fun(NODE *h) ing h 率*布布亭事 found*事事率*布率事*/ sno har name [10] while(p) float score3]: 率*布率率事事布 found布率率事事摩*/ /率事率布事事 found市事事率率事率*/ fun(struct student *a) /率*率事率率事foud市率率布率率*/ if(p->data 3 q->data) a->sno=10002 i t= p->data, p->data = q->data, q->data strcpy(a->name, "LiSi") /率率率 found水本率事**/ for(=0,inext= NULL, printf("nNo: %ld Name: %slnScores: "ssno, s name); for(i=0;inext= NULL printf("nThe data after modified n"); if(h->next==NULL) h->next=p=q: printf("nNo: %ld Name: %sunCor else p->next= p=4; j for(F0; KscoreD return printf("n"); void outlist(NODE·h) NODE·p 17、给定程序中,函数fun的功能是:计算形参x所指数组 p=h->next, 中N个数的平均值(规定所有数均为正数),将所指数组中 if(p=NULL) printf("The list is NULL! n") 大于平均值的数据移至数组的前部,小于等于平均值的数据 移至x所指数组的后部,平均值作为函数值返回,在主函数 i printf("nHead " 中输出平均值和移动后的数据。 例如,有10个正数:463032406174515 printi("->%d", p->data), p=p->next; 4826,平均值为:30.500000 while(p!=NULL); 移动后的输出为:463240454830617 printf("->EndIn"); 请在程序的下划线处填入正确的内容并把下划线删除 使程序得出正确的结果 注意:源程序存放在考生文件夹下的 BLANKLC中 i NODE*head 不得增行或删行,也不得更改程序的结构! int aIN]={0,10,4,2,8,6} #include head=creatlist(a) #include printf("\n The original list: In"); #define N 10

宏为世纪教育 www.greatc.cn 4 月上机考试题库 填空题 5 printf("\nThe result is: %d\n\n",n); } 15、给定程序中,函数 fun 的功能是将带头节点的单向链表结 点数据域中的数据从小到大排序。即若原链表结点数据域从 头至尾的数据为:10、4、2、8、6,排序后链表结点数据域 从头至尾的数据为:2、4、6、8、10。 请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1.C 中。 不得增行或删行,也不得更改程序的结构! #include #include #define N 6 typedef struct node { int data; struct node *next; } NODE; void fun(NODE *h) { NODE *p, *q; int t; /**********found**********/ p = __1__ ; while (p) { /**********found**********/ q = __2__ ; while (q) { /**********found**********/ if (p->data __3__ q->data) { t = p->data; p->data = q->data; q->data = t; } q = q->next; } p = p->next; } } NODE *creatlist(int a[]) { NODE *h,*p,*q; int i; h = (NODE *)malloc(sizeof(NODE)); h->next = NULL; for(i=0; idata=a[i]; q->next = NULL; if (h->next == NULL) h->next = p = q; else { p->next = q; p = q; } } return h; } void outlist(NODE *h) { NODE *p; p = h->next; if (p==NULL) printf("The list is NULL!\n"); else { printf("\nHead "); do { printf("->%d", p->data); p=p->next; } while(p!=NULL); printf("->End\n"); } } main() { NODE *head; int a[N]= {0, 10, 4, 2, 8, 6 }; head=creatlist(a); printf("\nThe original list:\n"); outlist(head); fun(head); printf("\nThe list after sorting :\n"); outlist(head); } 16、程序通过定义学生结构体变量,存储了学生的学号、姓 名和 3 门课的成绩。函数 fun 的功能是将形参 a 所指结构体 变量 s 中的数据进行修改,并把 a中地址作为函数值返回主函 数,在主函数中输出修改后的数据。 例如:a 所指变量 s 中的学号、姓名、和三门课的成绩 依次是:10001、" ZhangSan "、95、80、88,修改后输出 t 中的数据应为:10002、"LiSi "、96、81、89。 请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1.C 中。 不得增行或删行,也不得更改程序的结构! #include #include struct student { long sno; char name[10]; float score[3]; }; /**********found**********/ __1__ fun(struct student *a) { int i; a->sno = 10002; strcpy(a->name, "LiSi"); /**********found**********/ for (i=0; isno, t->name); for (i=0; iscore[i]); printf("\n"); } 17、给定程序中,函数 fun 的功能是:计算形参 x 所指数组 中 N 个数的平均值(规定所有数均为正数),将所指数组中 大于平均值的数据移至数组的前部,小于等于平均值的数据 移至 x 所指数组的后部,平均值作为函数值返回,在主函数 中输出平均值和移动后的数据。 例如,有 10 个正数:46 30 32 40 6 17 45 15 48 26,平均值为:30.500000 移动后的输出为:46 32 40 45 48 30 6 17 15 26 请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1.C 中。 不得增行或删行,也不得更改程序的结构! #include #include #define N 10

eatc.cn4月上机考试题库填空 double fur #include i int i,j, double S, av, yIN; #include #define n 5 for(F0, K 使程序得出正确的结果 #define n 4 注意:源程序存放在考生文件夹下的 BLANKIO中 void fun(int(°a[N],int·b) 不得增行或删行,也不得更改程序的结构! #include for(F=0,i<N;计++){ bOF for(F1; j<N; j++) i if(s!='&& flag==0)i /率布率春事 found布率率布率*/ 率*布亭事率率 found事事事*率事事市/ if(b2 adlo b=anIo 冰率*布事率事事布 found布春亭率布摩/ ifs==) maino /率率布率事布fnd事本亭事率/ xNN={{12,5.8,7},{6,1,9,3},{1,2,3,4},{2,84,3}}yN]j printf("nThe matrix: n"); for(F=0,i<N,计++) i for(F0; j <N; j++) printf("%4d"[: maino int n printf("eNter a line text: n"); gets(str); /率事事率布事 found市事事率*事率*/ n=fun(str) printf("n There are %d words in this text. nn,n); printf("nThe result is: ) for(F0; K<N; i++) printf("%3d",y) printf("n") 19、给定程序中,函数fun的功能是:在形参ss所指字 串数组中查找与形参t所指字符串相同的串,找到后返回该 串在字符串数组中的位置(下标值),未找到则返回1。s21、给定程序中,函数fun的功能是:判断形参s所指字符 所指字符串数组中共有N个内容不同的字符串,且串长小串是否是回文”( Palindrome),若是,函数返回值为1:不 于M。 是,函数返回值为0。"回文"是正读和反读都一样的字符串 请在程序的下划线处填入正确的内容并把下划线删 (不区分大小写字母) 使程序得出正确的结果 例如, LEVEL和Leve是"回文",而 LEVLEV不是 注意:源程序存放在考生文件夹下的 BLANK1C中 回文”。 不得增行或删行,也不得更改程序的结构! 请在程序的下划线处填入正确的内容并把下划线删除

宏为世纪教育 www.greatc.cn 4 月上机考试题库 填空题 6 double fun(double *x) { int i, j; double s, av, y[N]; s=0; for(i=0; iav ){ /**********found**********/ y[__2__]=x[i]; x[i]=-1;} for(i=0; i int fun(char *s) { int n=0, flag=0; while(*s!='\0') { if(*s!=' ' && flag==0) { /**********found**********/ __1__ ; flag=1;} /**********found**********/ if (*s==' ') flag= __2__ ; /**********found**********/ __3__ ; } return n; } main() { char str[81]; int n; printf("\nEnter a line text:\n"); gets(str); n=fun(str); printf("\nThere are %d words in this text.\n\n",n); } 19、给定程序中,函数 fun 的功能是:在形参 ss 所指字符 串数组中查找与形参 t 所指字符串相同的串,找到后返回该 串在字符串数组中的位置(下标值),未找到则返回-1。ss 所指字符串数组中共有 N 个内容不同的字符串,且串长小 于 M。 请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1.C 中。 不得增行或删行,也不得更改程序的结构! #include #include #define N 5 #define M 8 int fun(char (*ss)[M],char *t) { int i; /**********found**********/ for(i=0; i #define N 4 void fun(int (*a)[N], int *b) { int i,j; for(i=0; i<N; i++) { /**********found**********/ b[i]= __1__; for(j=1; j<N; j++) /**********found**********/ if(b[i] __2__ a[j][i]) b[i]=a[j][i]; } } main() { int x[N][N]={ {12,5,8,7},{6,1,9,3},{1,2,3,4},{2,8,4,3} },y[N],i,j; printf("\nThe matrix :\n"); for(i=0;i<N; i++) { for(j=0;j<N; j++) printf("%4d",x[i][j]); printf("\n"); } /**********found**********/ fun(__3__); printf("\nThe result is:"); for(i=0; i<N; i++) printf("%3d",y[i]); printf("\n"); } 21、给定程序中,函数 fun 的功能是:判断形参 s 所指字符 串是否是"回文"(Palindrome),若是,函数返回值为 1;不 是,函数返回值为 0。"回文"是正读和反读都一样的字符串 (不区分大小写字母)。 例如,LEVEL 和 Level 是"回文",而 LEVLEV 不是" 回文"。 请在程序的下划线处填入正确的内容并把下划线删除

宏为世纪教育www.great4月上机考试题库填空是 使程序得出正确的结果 10004," FangFang",90,82,8 注意:源程序存放在考生文件夹下的 BLANKl.C中 10005," ZhangSan",95,80,88},ssN] 不得增行或删行,也不得更改程序的结构! FILE·fp #include fp= fopen("student. dat","wb #include # include iclose(fp) int fun( char *s) printf("nThe original data: n"); char *Ip,’p fp= fopen("student. dat","rb"); /**布率事布 found事事事事*/ fread(ss, sizeof(STU), N, fp); while(( toupper(IpF=toupper(rp))&&(lp 请在程序的下划线处填入正确的内容并把下划线删除 #define n 5 使程序得出正确的结果 typedef struct student 注意:源程序存放在考生文件夹下的 BLANKLC中。 不得增行或删行,也不得更改程序的结构! char name[ 10]; #include float score3]; #include <string. h A STU struct student i void fun( char *filename, long sno) long sno, STU n float score3]: 率*布事率布布 found布事率率布事率*/ void fun( struct student *b) while(feof(I)) f in i fread( &n, sizeof(STU), 1, fp); /率春率率布摩 found*事率率事**/ if(nsno 2 sno) if (I feof(fp)) for(F=0;κ<3;计++)n. score[+=3 /**布事率率布foun i struct student t( 10002, "Zhang Q1,93, 85,; 3, -1(long)sizeof(STU), SEEK CUR); fwrite( &n, sizeof(STU), 1, fp); printf("nln The original data n"); printf("nNo: %ld Name: %snScores: " tsno, tname); fclose(fp) for(F0; K <3: 1++) printi(%6.2f",t. D: STU tIN}={{10001, Macha",91,92,77} fun(3_), {10002," Caokai",75,60,88} printf("nThe data after modified: n"); 10003,"Ls, printf("\nNo: %ld Name: %slnScores: ", tsno, tname);

宏为世纪教育 www.greatc.cn 4 月上机考试题库 填空题 7 使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1.C 中。 不得增行或删行,也不得更改程序的结构! #include #include #include int fun(char *s) { char *lp,*rp; /**********found**********/ lp= __1__ ; rp=s+strlen(s)-1; while((toupper(*lp)==toupper(*rp)) && (lp #define N 5 typedef struct student { long sno; char name[10]; float score[3]; } STU; void fun(char *filename, long sno) { FILE *fp; STU n; int i; fp = fopen(filename,"rb+"); /**********found**********/ while (!feof(__1__)) { fread(&n, sizeof(STU), 1, fp); /**********found**********/ if (n.sno__2__sno) break; } if (!feof(fp)) { for (i=0; i #include struct student { long sno; char name[10]; float score[3]; }; void fun( struct student *b) { int i; /**********found**********/ b__1__ = 10004; /**********found**********/ strcpy(b__2__, "LiJie"); } main() { struct student t={10002,"ZhangQi", 93, 85, 87}; int i; printf("\n\nThe original data :\n"); printf("\nNo: %ld Name: %s\nScores: ",t.sno, t.name); for (i=0; i<3; i++) printf("%6.2f ", t.score[i]); printf("\n"); /**********found**********/ fun(__3__); printf("\nThe data after modified :\n"); printf("\nNo: %ld Name: %s\nScores: ",t.sno, t.name);

宏为世纪教育www.greatc4月上机考试题库填空题 for(F0; 1e) /率事布事事事摩 found事事率事事摩率*/ 24、给定程序中,函数fun的功能是:计算形参x所指数组 中N个数的平均值(规定所有数均为正数),将所指数组中事事幸春und幸春* 小于平均值的数据移至数组的前部,大于等于平均值的数据 川(3)*(20*) 移至x所指数组的后部,平均值作为函数值返回,在主函数 中输出平均值和移动后的数据。 例如,有10个正数:46 4826,平均值为:30.500000 移动后的输出为:306171526463240 maino 4548 i double e=le-3 请在程序的下划线处填入正确的内容并把下划线删除 printf("nThe result is: %f\n", fun(e); 使程序得出正确的结果 注意:源程序存放在考生文件夹下的 BLANKLO中 不得增行或删行,也不得更改程序的结构! 26、给定程序中,函数fun的功能是建立一个NxN的矩阵 矩阵元素的构成规律是:最外层元素的值全部为1:从外向 内第2层元素的值全部为2:第3层元素的值全部为3 #define N 依次类推。例如,若N=5,生成的矩阵为 double fun( double *x) i int i,]: double av, yN: av=0. l232 率*布率率事事布 found布率率事事摩*/ 12221 for(F0; K fx[=-1)y[++=x[; 率*布布亭事布 found布事率率事春事事/ void fun(int(·a)_1) i int i,j, k, m; ifN‰2=0)m=N/2 for(=0,iN,计+)=y N2+1; r(=0,im,i++){ /率事事事* found事事*事**/ double xN: 可=a for(F0; I 注意:源程序存放在考生文件夹下的 BLANKLC中 double fun( double e 不得增行或删行,也不得更改程序的结构 f int i; double s,x; #include /率率布布摩率率布 found事亭事布事事率*/ double fI(double x)

宏为世纪教育 www.greatc.cn 4 月上机考试题库 填空题 8 for (i=0; i #include #define N 10 double fun(double *x) { int i, j; double av, y[N]; av=0; /**********found**********/ for(i=0; i double fun(double e) { int i; double s, x; /**********found**********/ s=0; i=__1__; x=1.0; while(x>e){ /**********found**********/ __2__; /**********found**********/ x=(2.0*i-1)/((__3__)*(2.0*i)); s=s+x; } return s; } main() { double e=1e-3; printf("\nThe result is: %f\n",fun(e)); } 26、给定程序中,函数 fun 的功能是建立一个 N×N 的矩阵。 矩阵元素的构成规律是:最外层元素的值全部为 1;从外向 内第 2 层元素的值全部为 2;第 3 层元素的值全部为 3,… 依次类推。例如,若 N=5,生成的矩阵为: 1 1 1 1 1 1 2 2 2 1 1 2 3 2 1 1 2 2 2 1 1 1 1 1 1 请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1.C 中。 不得增行或删行,也不得更改程序的结构! #include #define N 7 /**********found**********/ void fun(int (*a) __1__) { int i,j,k,m; if(N%2==0) m=N/2 ; else m=N/2+1; for(i=0; i double f1(double x)

eatc.cn4月上机考试题库填空 return x'x. 注意:源程序存放在考生文件夹下的 BLANK1C中 double f2(double x, double y) 不得增行或删行,也不得更改程序的结构! i return x*y: j #include double fun(double a, double b) double fun(int n) 率*布亭事率率 found事事事*率事事市/ (f)O, /率事事事率 found*事亭率事事事事率率/ double r1 r2 /**布率事布 found事事事事*/ point fountic s=s+k*(2*-1)°(2*+1)t·t / point fountion f2*/ 2=(·f)a,b) k=k*3 eturn r1+r2 return s maino i double xl=5, x2=3, r, r= fun(x1, x2); printf("nxl=%f, x2=%f, xl xl+xI*x2=%fn,x1, x2, r); i printf("Please input(n>0): " ) scanf("%d", &n); printi("nThe result is: %f\n", fun(n)); 28、给定程序中,函数fun的功能是将参数给定的字符串、整 数、浮点数写到文本文件中,再用字符串方式从此文本文件 中逐个读入,并调用库函数atoi和atof将字符串转换成相应30、程序通过定义学生结构体变量,存储了学生的学号、姓 整数、浮点数,然后将其显示在屏幕上。 名和3门课的成绩。所有学生数据均以二进制方式输出到文 请在程序的下划线处填入正确的内容并把下划线删除,件中。函数fun的功能是重写形参 filen ame所指文件中最后 使程序得出正确的结果 个学生的数据,即用新的学生数据覆盖该学生原来的数据 注意:源程序存放在考生文件夹下的 BLANK1C中 其它学生的数据不变。 不得增行或删行,也不得更改程序的结构! 清在程序的下划线处填入正确的内容并把下划线删除 #include 使程序得出正确的结果。 #include 注意:源程序存放在考生文件夹下的 BLANKLC中 void fun(char *s, int a, double f) 不得增行或删行,也不得更改程序的结构! #include /*率事事率*布布 found布*事事*/ #define N 5 typedef struct student char str[100, strl[100, str2[100- double fl har name[10] fp= fopen("filel. txt,"W: float score3]; fprintf(fp, "%s %d %f\n",s, a, f); A STU: void fun(char *filename, STU n fp=fopen("filel. txt,"r"; /率事事* found*事事事事事率率/ 率*布率率事事布 found布率率事事摩*/ fp= fopen(_1_,"b+"); /率率布摩 found*事率率率帝率布/ fclose(fp) fseek(2 ,-(long) " sizeof(STU), SEEK_END); al = atoi(str1); /率布率春事 found市事率率枣事事率 fwrite( &n, sizeof(STU), 1, 3 printf("\n The result: \nIn%s%d %f\",str, al, f1 ); fclose(fp); main( i char a[10]"Hello! tb=12345 ItNF{10001," Macha",91,92,77}, double c=98.76 10002," CaoKai",75,60,88} fun(a, b, c) {10003,"Lsi 10004," FangFang",90,82,87} 29、给定程序中,函数fun的功能是:计算下式前n项的和STUn={10006," Zhaosi,55,70,68},ssN] 作为函数值返回 1(2×n-1)×(2Xn+D fp=fopen("student. dat","wb"); fwrite(t, sizeof(STU), N, fp) 例如,当形参n的值为10时,函数返回:-0.204491 fread(ss, sizeof(STU), N, fp); 请在程序的下划线处填入正确的内容并把下划线删除 fclose(fp); 使程序得出正确的结果。 printf("inThe original data: nln")

宏为世纪教育 www.greatc.cn 4 月上机考试题库 填空题 9 { return x*x; } double f2(double x, double y) { return x*y; } double fun(double a, double b) { /**********found**********/ __1__ (*f)(); double r1, r2; /**********found**********/ f = __2__ ; /* point fountion f1 */ r1 = f(a); /**********found**********/ f = __3__ ; /* point fountion f2 */ r2 = (*f)(a, b); return r1 + r2; } main() { double x1=5, x2=3, r; r = fun(x1, x2); printf("\nx1=%f, x2=%f, x1*x1+x1*x2=%f\n",x1, x2, r); } 28、给定程序中,函数 fun 的功能是将参数给定的字符串、整 数、浮点数写到文本文件中,再用字符串方式从此文本文件 中逐个读入,并调用库函数 atoi 和 atof 将字符串转换成相应 的整数、浮点数,然后将其显示在屏幕上。 请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1.C 中。 不得增行或删行,也不得更改程序的结构! #include #include void fun(char *s, int a, double f) { /**********found**********/ __1__ fp; char str[100], str1[100], str2[100]; int a1; double f1; fp = fopen("file1.txt", "w"); fprintf(fp, "%s %d %f\n", s, a, f); /**********found**********/ __2__ ; fp = fopen("file1.txt", "r"); /**********found**********/ fscanf(__3__,"%s%s%s", str, str1, str2); fclose(fp); a1 = atoi(str1); f1 = atof(str2); printf("\nThe result :\n\n%s %d %f\n", str, a1, f1); } main() { char a[10]="Hello!"; int b=12345; double c= 98.76; fun(a,b,c); } 29、给定程序中,函数 fun 的功能是:计算下式前 n 项的和 作为函数值返回。 例如,当形参 n 的值为 10 时,函数返回:-0.204491。 请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1.C 中。 不得增行或删行,也不得更改程序的结构! #include double fun(int n) { int i, k; double s, t; s=0; /**********found**********/ k=__1__; for(i=1; i0): "); scanf("%d",&n); } printf("\nThe result is: %f\n",fun(n)); } 30、程序通过定义学生结构体变量,存储了学生的学号、姓 名和 3 门课的成绩。所有学生数据均以二进制方式输出到文 件中。函数 fun 的功能是重写形参 filename 所指文件中最后 一个学生的数据,即用新的学生数据覆盖该学生原来的数据, 其它学生的数据不变。 请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1.C 中。 不得增行或删行,也不得更改程序的结构! #include #define N 5 typedef struct student { long sno; char name[10]; float score[3]; } STU; void fun(char *filename, STU n) { FILE *fp; /**********found**********/ fp = fopen(__1__, "rb+"); /**********found**********/ fseek(__2__, -(long)*sizeof(STU), SEEK_END); /**********found**********/ fwrite(&n, sizeof(STU), 1, __3__); fclose(fp); } main() { STU t[N]={ {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}}; STU n={10006,"ZhaoSi", 55, 70, 68}, ss[N]; int i,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 :\n\n");

宏为世纪教育www.greatc4月上机考试题库填 for ( F0; j 使程序得出正确的结果。 #define N 10 注意:源程序存放在考生文件夹下的 BLANKLC中 double fun( double x[, double *av) 不得增行或删行,也不得更改程序的结构! i int ij: #include for(=0,iN,计+)s=s+x[ struct student i 率亭事事事foud事事率率布事事*/ har name[10] d=3276 float score3] for(F=0,i 34、给定程序中,函数fun的功能是:利用指针数组对形参 ss所指字符串数组中的字符串按由长到短的顺序排序,并输

宏为世纪教育 www.greatc.cn 4 月上机考试题库 填空题 10 for (j=0; j #define N 10 double fun(double x[],double *av) { int i,j; double d,s; s=0; for(i=0; i void fun(char *s, int a, double f) { /**********found**********/ __1__ fp; char ch; fp = fopen("file1.txt", "w"); fprintf(fp, "%s %d %f\n", s, a, f); fclose(fp); fp = fopen("file1.txt", "r"); printf("\nThe result :\n\n"); ch = fgetc(fp); /**********found**********/ while (!feof(__2__)) { /**********found**********/ putchar(__3__); ch = fgetc(fp); } putchar('\n'); fclose(fp); } main() { char a[10]="Hello!"; int b=12345; double c= 98.76; fun(a,b,c); } 33、程序通过定义学生结构体变量,存储了学生的学号、姓 名和 3 门课的成绩。函数 fun 的功能是将形参 a 中的数据进 行修改,把修改后的数据作为函数值返回主函数进行输出。 例如:传给形参 a 的数据中,学号、姓名、和三门课的 成绩依次是:10001、"ZhangSan"、95、80、88,修改后的 数据应为:10002、"LiSi"、96、81、89。 请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1.C 中。 不得增行或删行,也不得更改程序的结构! #include #include struct student { long sno; char name[10]; float score[3]; }; /**********found**********/ __1__ fun(struct student a) { int i; a.sno = 10002; /**********found**********/ strcpy(__2__, "LiSi"); /**********found**********/ for (i=0; i<3; i++) __3__+= 1; return a; } main() { struct student s={10001,"ZhangSan", 95, 80, 88}, t; int i; printf("\n\nThe original data :\n"); printf("\nNo: %ld Name: %s\nScores: ",s.sno, s.name); for (i=0; i<3; i++) printf("%6.2f ", s.score[i]); printf("\n"); t = fun(s); printf("\nThe data after modified :\n"); printf("\nNo: %ld Name: %s\nScores: ",t.sno, t.name); for (i=0; i<3; i++) printf("%6.2f ", t.score[i]); printf("\n"); } 34、给定程序中,函数 fun 的功能是:利用指针数组对形参 ss 所指字符串数组中的字符串按由长到短的顺序排序,并输

点击下载完整版文档(DOC)VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
共16页,试读已结束,阅读完整版请下载
相关文档

关于我们|帮助中心|下载说明|相关软件|意见反馈|联系我们

Copyright © 2008-现在 cucdc.com 高等教育资讯网 版权所有