mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
Create 1757.c
This commit is contained in:
parent
91e473ce32
commit
cb2c8ec38d
31
QUSTOJ/1757.c
Normal file
31
QUSTOJ/1757.c
Normal 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;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user