2017.11 程序设计基础月考

C. 字符串替换

单点时限: 1.0 sec

内存限制: 256 MB

//********** Specification of replace **********
void replace(char s[], char x[], char y[]);
/* Precondition: s, x and y are three strings, 
                and s has enough memory to store modified string 
   Postcondition: replace all substring x with y in string s
*/

void replace(char s[], char x[], char y[]) { //TODO: your function definition

}

#include <stdio.h>

#define N 80

int main() {
    char s[3 * N + 1], x[N + 1], y[N + 1];
    scanf("%s%s%s", s, x, y);
    replace(s, x, y);
    printf("%s\n", s);
    return 0;
}

样例

Input
iamstupid stupid clever
Output
iamclever

提示

The input consists of three strings $s,x,y$ ($1 \le |s|, |x|, |y| \le 80$), where $|s|$ is the length of $s$. All strings appearing in the input consist only of ascii lowercase letters.

$x$ will not overlap in $s$, but can repeat. It is guaranteed the answer $s’$ satisfies $1 \le |s’| \le 240$.