69,371
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <string.h>
#include <assert.h>
bool isTuoFengStr(char *strSor)
{
assert(strSor);
if(*strSor==*(strSor+2)) return true;
else return false;
}
char* cutTuoFeng (char *strSor)
{
bool flag=false;
char *result,*p=strSor;
result=p;
while(*p!='\0')
{
flag=isTuoFengStr(p);
if(true==flag)
{
strcpy(p,p+3);
p=strSor;
}
else p++;
}
return result;
}
int main()
{
char a[50];
printf("Please input a string:");
scanf("%s",a);
char *res;
printf("(%s) delete Tuofeng string is:",a);
res=cutTuoFeng(a);
printf("%s\n",res);
return 0;
}
#include <stdio.h>
#include <string.h>
void proc_s(char *buff)
{
char *tmp;
char result[200],*r;
// int i;
int stat;
do {
stat=0;
tmp=buff;
r=result;
while(*tmp)
{
if (*tmp==*(tmp+2))
{
tmp+=3;
stat=1;
}
else
*r++=*tmp++;
}
*r='\0';
memset(buff,0,200);
strcpy(buff,result);
}while(stat==1);
}
int main()
{
char buff[200];
memset(buff,0,sizeof(buff));
gets(buff);
printf("old str=%s\n",buff);
proc_s(buff);
printf("new str=%s\n",buff);
}