3445. 字符串替换

单点时限: 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$.

572 人解决,743 人已尝试。

880 份提交通过,共有 4482 份提交。

2.2 EMB 奖励。

创建: 6 年,4 月前.

修改: 6 年,4 月前.

最后提交: 1 月前.

来源: 2017.11 程序设计基础月考

题目标签