正在加载图片...
宏为世纪教育www.greatc4月上机考试题库填空题 出排序结果。ss所指字符串数组中共有N个字符串,且串{ char s|80] 长小于M printf("Please input: ") scanf("%s"S); 请在程序的下划线处填入正确的内容并把下划线删除, printf("nThe result An", fun(s); 使程序得出正确的结果 注意:源程序存放在考生文件夹下的 BLANK1C中 不得增行或删行,也不得更改程序的结构 36、给定程序中,函数fum的功能是计算下式 #include <stdio. h> #include <string. h #define n 5 (2xn) #define void fun(char (Ss)MD i char "psN, tp: int i,j, k; 直到×+≤103,并把计算结果作为函数值返回 for(i=0; I<N; H+)ps[=ss[]: for(=0,iN-1;计++){ 例如:若形参e的值为le3,函数的返回值为0.551690。 /率率布*** found*事亭事事春事率 请在程序的下划线处填入正确的内容并把下划线删 使程序得出正确的结果。 fo(=计+1;j<N;j++) 注意:源程序存放在考生文件夹下的 BLANKLO中 率*布布亭率事布布foud布事事率*布事事/ 不得增行或删行,也不得更改程序的结构! if(strlen(ps[)<strlen(2))kj; #include <stdio h> /*率布事率布 found事*率事事率/ double fun(double e tp=ps: ps(= k]; ps[k= 3 double s, t x s=0,k=1;F=2 printf("nThe string after sorting by length: nIn"); /率事* found*事率事春事事事率 for(F0; K<N; 1+)puts(psO) /率布率布布 found*事事率事事事事率/ i char chINJIMEf"red","green","blue", yellow", black") (-1), printf("n The original string nn); for(F0 K <N; i++)puts(ch]), printf("n); found市事摩率 35、给定程序中,函数fn的功能是:将形参s所指字符串 return S 中的所有字母字符顺序前移,其他字符顺序后移,处理后新} 字符串的首地址作为函数值返回。 main( 例如,s所指字符串为asd23gh543d处理后新字符串 double e=le-3 为 casdfghdi2543 请在程序的下划线处填入正确的内容并把下划线删除 )ntf("n The result is: %fn, fun(e); 使程序得出正确的结果 注意:源程序存放在考生文件夹下的 BLANKLO中。37、给定程序中,函数fun的功能是:将形参n所指变量中 不得增行或删行,也不得更改程序的结构! 各位上为偶数的数去除剩余的数按原来从高位到低位的顺 #include <stdio. h> 序组成一个新的数,并通过形参指针n传回所指变量 #include <stdlib. h> 例如,输入一个数:27638496,新的数:为739。 #include 请在程序的下划线处填入正确的内容并把下划线删除, char *fun(char *s) 使程序得出正确的结果。 inti,,k,n,char·p,t 注意:源程序存放在考生文件夹下的 BLANKLC中 n=strlen(s)+ 不得增行或删行,也不得更改程序的结构! t(char")malloc(n*sizeof( char)) #include <stdio. h> p=(char*)malloc(n*sizeof(char) void fun(unsigned long *n) for(i=0,i<n;计++) F=1 f((s[=a)&(s[<=2)([=A&(s[叮<=Z)){ while( "n) 率率率率率率率市 found市事率率事事事摩率 /率布布事率* found事事**布率*/ =n%_1 pk|=sk++,} (X=X+t*i, 率*布率率事事布 found布率率事事摩*/ 率n=n/10 for(=0,2_;计++)tp[ /率事事事事率 found*率事事事事率率/ } maino i unsigned long n=-1 11宏为世纪教育 www.greatc.cn 4 月上机考试题库 填空题 11 出排序结果。ss 所指字符串数组中共有 N 个字符串,且串 长小于 M。 请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1.C 中。 不得增行或删行,也不得更改程序的结构! #include <stdio.h> #include <string.h> #define N 5 #define M 8 void fun(char (*ss)[M]) { char *ps[N],*tp; int i,j,k; for(i=0; i<N; i++) ps[i]=ss[i]; for(i=0; i<N-1; i++) { /**********found**********/ k= __1__ ; for(j=i+1; j<N; j++) /**********found**********/ if(strlen(ps[k]) < strlen(__2__) ) k=j; /**********found**********/ tp=ps[i]; ps[i]=ps[k]; ps[k]= __3__ ; } printf("\nThe string after sorting by length:\n\n"); for(i=0; i<N; i++) puts(ps[i]); } main() { char ch[N][M]={"red","green","blue","yellow","black"}; int i; printf("\nThe original string\n\n"); for(i=0;i<N;i++)puts(ch[i]); printf("\n"); fun(ch); } 35、给定程序中,函数 fun 的功能是:将形参 s 所指字符串 中的所有字母字符顺序前移,其他字符顺序后移,处理后新 字符串的首地址作为函数值返回。 例如,s 所指字符串为:asd123fgh543df,处理后新字符串 为:asdfghdf12543。 请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1.C 中。 不得增行或删行,也不得更改程序的结构! #include <stdio.h> #include <stdlib.h> #include <string.h> 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<n; i++) { if(((s[i]>='a')&&(s[i]<='z'))||((s[i]>='A')&&(s[i]<='Z'))) { /**********found**********/ t[j]=__1__; j++;} else { p[k]=s[i]; k++; } } /**********found**********/ for(i=0; i<__2__; i++) t[j+i]=p[i]; /**********found**********/ t[j+k]= __3__; return t; } main() { char s[80]; printf("Please input: "); scanf("%s",s); printf("\nThe result is: %s\n",fun(s)); } 36、 例如:若形参 e 的值为 1e-3,函数的返回值为 0.551690。 请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1.C 中。 不得增行或删行,也不得更改程序的结构! #include <stdio.h> double fun(double e) { int i, k; double s, t, x; s=0; k=1; i=2; /**********found**********/ x=__1__/4; /**********found**********/ while(x __2__ e) { s=s+k*x; k=k* (-1); t=2*i; /**********found**********/ x=__3__/(t*t); i++; } return s; } main() { double e=1e-3; printf("\nThe result is: %f\n",fun(e)); } 37、给定程序中,函数 fun 的功能是:将形参 n 所指变量中, 各位上为偶数的数去除,剩余的数按原来从高位到低位的顺 序组成一个新的数,并通过形参指针 n 传回所指变量。 例如,输入一个数:27638496,新的数:为 739。 请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1.C 中。 不得增行或删行,也不得更改程序的结构! #include <stdio.h> void fun(unsigned long *n) { unsigned long x=0, i; int t; i=1; while(*n) /**********found**********/ { t=*n % __1__; /**********found**********/ if(t%2!= __2__) { x=x+t*i; i=i*10; } *n =*n /10; } /**********found**********/ *n=__3__; } main() { unsigned long n=-1;
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有