/*编写函数squeeze(s1,s2),将字符串s1中任何与字符串s2中字符匹配的字符都删掉*/
char * squeeze(char * ds,char *ss)
{
int i=0;
char *iter=ds,*head=ss;
for(;*ds!='/0';ds++){
head=ss;
for(;*head!='/0';head++){
if( *ds==*head)break;
}
if(*head =='/0')iter[i++]=*ds;/*全都不匹配*/
}
iter[i]='/0';
return iter;
}
博客给出了一个编写函数squeeze(s1, s2)的代码,该函数的功能是将字符串s1中与字符串s2中字符匹配的字符都删掉。代码通过两层循环遍历字符串,若不匹配则保留字符。
2万+

被折叠的 条评论
为什么被折叠?



