33、給定程序中,函數(shù)fun的功能是:將形參s所指字符串中所有ASCII碼值小于97的字符存入形參t所指字符數(shù)組中,形成一個(gè)新串,并統(tǒng)計(jì)出符合條件的字符個(gè)數(shù)作為函數(shù)值返回。
例如,形參s所指的字符串為:Abc@1x56*,程序執(zhí)行后t所指字符數(shù)組中的字符串應(yīng)為:A@156*。
請(qǐng)?jiān)诔绦虻南聞澗€處填入正確的內(nèi)容并把下劃線刪除, 使程序得出正確的結(jié)果。
注意:源程序存放在考生文件夾下的BLANK1.C中。
不得增行或刪行,也不得更改程序的結(jié)構(gòu)!
#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("\nEnter a string:\n"); gets(s);
n=fun(s,t);
printf("\nThere are %d letter which ASCII code is less than 97: %s\n",n,t);
}
34、給定程序中,函數(shù)fun的功能是:將形參s所指字符串中的所有字母字符順序前移,其他字符順序后移,處理后新字符串的首地址作為函數(shù)值返回。
例如,s所指字符串為:asd123fgh543df,處理后新字符串為:asdfghdf123543。
請(qǐng)?jiān)诔绦虻南聞澗€處填入正確的內(nèi)容并把下劃線刪除,使程序得出正確的結(jié)果。
注意:源程序存放在考生文件夾下的BLANK1.C中。
不得增行或刪行,也不得更改程序的結(jié)構(gòu)!
#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**********/
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));
}