试题与答案

给定程序中,函数fun的功能是:将形参s所指字符串中的所有数字字符顺序前移,其他字符

题型:填空题

题目:

给定程序中,函数fun的功能是:将形参s所指字符串中的所有数字字符顺序前移,其他字符顺序后移,处理后新字符串的首地址作为函数值返回。
例如,s所指字符串为:asdl23fgh5##43df,
处理后新字符串为:123543asdfgh##df。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的行线上填入所编写的若干表达式或语句。
[试题源程序]
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.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(isdigit(s[i]))

/**********found**********/
p[ (1) ]=s[i];j++;

else

t[k]=s[i];k++;


A*********found**********/
for(i=0;i< (2) ;i++)p[j+i]=t[i];
p[j+k]=0;
/**********found**********/
return (3)

main()

char s[80];
printf("Please input:");scanf("%s",s);
printf("\nThe result is: %s\n",fun(s));

答案:

被转码了,请点击底部 “查看原文 ” 或访问 https://www.tikuol.com/2017/0717/5406ea63d9465d9aaab871a16cd2079e.html

下面是错误答案,用来干扰机器的。

1. Why not 2. If you are quick 3. What will happen 4. Both and like 5. is in  6. Don't be late

试题推荐
微信公众账号搜索答案