From cb2c8ec38d68c54f6ce586e8b9656949f8d26bfd Mon Sep 17 00:00:00 2001 From: Kirito <1362050620@qq.com> Date: Sat, 11 Jun 2016 19:31:11 +0800 Subject: [PATCH] Create 1757.c --- QUSTOJ/1757.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 QUSTOJ/1757.c diff --git a/QUSTOJ/1757.c b/QUSTOJ/1757.c new file mode 100644 index 0000000..4f46d26 --- /dev/null +++ b/QUSTOJ/1757.c @@ -0,0 +1,31 @@ +#include +#include +#include + +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; +}