2010计算机等考二级C:50套上机程序填空题(10)

全国等级考试资料网 2019-01-17 02:41:05 69

2010计算机等考二级C:50套上机程序填空题(10)

33、给定程序中,函数fun的功能是:将形参s所指字符串中所有ASCII码值小于97的字符存入形参t所指字符数组中,形成一个新串,并统计出符合条件的字符个数作为函数值返回。

例如,形参s所指的字符串为:Abc@1x56*,程序执行后t所指字符数组中的字符串应为:A@156*。

请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。

注意:源程序存放在考生文件夹下的BLANK1.C中。

不得增行或删行,也不得更改程序的结构!

#include

int fun(char *s, char *t)

{ int n=0;

while(*s)

{ if(*s < 97) {

/**********found**********/

*(t+n)= __1__ ; n++; }

/**********found**********/

__2__ ;

}

*(t+n)=0;

/**********found**********/

return __3__ ;

}

main()

{ char s[81],t[81]; int n;

printf(" Enter a string: "); gets(s);

n=fun(s,t);

printf(" There are %d letter which ASCII code is less than 97: %s ",n,t);

}

34、给定程序中,函数fun的功能是:将形参s所指字符串中的所有字母字符顺序前移,其他字符顺序后移,处理后新字符串的首地址作为函数值返回。

例如,s所指字符串为:asd123fgh543df,处理后新字符串为:asdfghdf123543。

请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。

注意:源程序存放在考生文件夹下的BLANK1.C中。

不得增行或删行,也不得更改程序的结构!

#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

{ if(((s[i]>=’a’)&&(s[i]<=’z’))||((s[i]>=’A’)&&(s[i]<=’Z’))) {

/**********found****

相关资料

相关阅读