OJ-Problems-Source/QUSTOJ/1757.c
2016-06-11 19:31:11 +08:00

32 lines
535 B
C

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void replace(char* str,char* From,char* To)
{
static char buffer[1024];
int L=strlen(From);
char* p;
while((p=strstr(str,From))!=NULL)
{
memset(buffer,0,1024);
strncpy(buffer,str,p-str);
strcat(buffer,To);
strcat(buffer,p+L);
strcpy(str,buffer);
}
}
char msg[1024];
char a[1024];
char b[1024];
int main()
{
gets(msg);
gets(a);
gets(b);
replace(msg,a,b);
printf("%s\n",msg);
return 0;
}