- 子串清除
- 2017-08-27 15:30:26 @
program Project1;
var
s1, s, ss: string;
i, j, k, m, n, len, ans: longint;
begin
readln(s1);
readln(s);
len := length(s1);
n := length(s);
i := 1;
j := len;
ans := 0;
repeat
if j > n then
begin
writeln(ans);
exit;
end
else
begin
ss := copy(s, i, j - i + 1);
if s1 = ss then
begin
Delete(s, i, j - i + 1);
n := n - len;
Inc(ans);
if i > len-1 then
begin
i := i - len + 1;
j := j - len + 1;
end;
end
else
begin
Inc(i);
Inc(j);
end;
end;
until 0 = 1;
end.
0 条评论
目前还没有评论...