1、题目
编写一个函数,利用指针实现对只包含字母和 * 号的字符串处理。将字符串中的开头连续的 * 号全部移到字符串的尾部
要求使用子函数:char* StrDel(char *s)
示例:
输入:***** st *** ring
输出:st *** ring *****
2、完整代码
#include <stdio.h>
char *StrDel(char* s)
{
char b[81];
char* c, * d;
c = s;
int i = 0;
while (*c == '*')
{
c++;
}
d = c;
while (*c != '\0')
{
b[i] = *c;
i++;
c++;
}
int e = 0;
while (s < d)
{
b[i] = *s;
i++;
s++;
e++;
}
s = s - e;
for (int j = 0; j < i; j++)
{
*s = b[j];
s++;
}
*s = '\0';
}
void main()
{
char s[81]; int n = 0;
gets(s);
StrDel(s);
puts(s);
}