0
点赞
收藏
分享

微信扫一扫

PAT 7-29 删除字符串中的子串

天使魔鬼 2022-04-24 阅读 55
c++

在这里插入图片描述

#include<stdio.h>
#include <string.h>

int main()
{

	char S1[81]="\0",S2[81]="\0",t[81]="\0",*p=NULL;
	gets(S1);
	gets(S2);
	int num2=strlen(S2);
	while((p=strstr(S1,S2))!=NULL)
	{
		strcpy(t,p+num2);
		*p='\0';
		strcat(S1,t);	
	}
	printf("%s\n",S1);
	return 0;
}
	
举报

相关推荐

0 条评论