Create 1757.c

pull/21/head^2
Kirigaya Kazuto 2016-06-11 19:31:11 +08:00 committed by GitHub
parent 91e473ce32
commit cb2c8ec38d
1 changed files with 31 additions and 0 deletions

31
QUSTOJ/1757.c Normal file
View File

@ -0,0 +1,31 @@
#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;
}