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$.

348 人解决,483 人已尝试。

592 份提交通过,共有 3083 份提交。

2.9 EMB 奖励。

创建: 2 年,9 月前.

修改: 2 年,9 月前.

最后提交: 4 天,2 小时前.

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

题目标签