填空题
请补充函数proc(),该函数的功能是:把一个字符串中的数字字符按从大到小的顺序排序,并把这个全部由数字组成的字符串保存在原串中,函数返回数字字符串的长度。例如,若输入字符串为“abc123def”,如果为321,字符串长度为3。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#define M 20
int proc(char *str)
{
int i=0, j=0, k=0, m=0;
char t;
char *p=str;
while(*p)
{
if(*p>="0"&&*p<="9")
1;
p++;
}
*(str+i)="/0";
2;
while(*(p+j))
{
k=j;
3;
while(*(p+k))
{
if(*(p+k)>*(str+m))
{
t=*(str+m);
*(str+m)=*(p+k);
*(p+k)=t;
}
k++;
}
j++;
}
return i;
}
void main()
{
char str[81];
int n;
system("CLS");
printf("Input the original string");
gets(str);
printf("***The original string***/n");
puts(str);
printf("***The new string***/n");
n=proc(str);
puts(str);
printf("***The length of new string is: %d***/n", n);
}