规定输入的字符串中只包含字母和*
号。给定程序的功能是将字符串中的前导*
号全部移到字符串的尾部。请将程序补充完整,使其能正确运行得出结果。
#include <stdio.h>
void fun( char *a )
{
int i=0,n=0;
char *p;
p=a;
while (*p=='*')
{
p++;
/***** 请在以下一行填写代码 *****/
n++;
}
while(*p)
{
/***** 请在以下一行填写代码 *****/
a[i]=*p;
i++;
p++;
}
while(n!=0)
{
a[i]='*';
i++;
/***** 请在以下一行填写代码 *****/
n--;
}
a[i]='\0';
}
int main()
{
char s[81];
int n=0;
scanf("%s",s);
fun( s );
printf("The string after oveing: \n");
puts(s);
return 0;
}