求一道c语言的题目答案

2025-02-22 22:54:44
推荐回答(2个)
回答1:

#include

int main()

{char s[]="I am a ***student,you ***are **a teach*****er.";

char *p,*q;

for(p=q=s;*p;p++)

if(*p!='*')*q++=*p;

*q='\0';  

printf("%s\n",s);

return 0;

}

回答2:

#include
#include
int main()
{
char s[]="I am a ***student,you ***are **a teach*****er."
int i,j=0;
for(i=0;s[i]!='\0';i++)
if(s[i]!='*')
{
s[i]=s[j];
j++;
}
s[j++]!='\0';
puts(s);
return 0;
}