Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var
- s, last, now: string;
- i, left: Integer;
- begin
- Readln(s);
- i := length(s);
- while s[i] <> ' ' do
- dec(i);
- last := copy(s, i + 1, length(s) - i + 1);
- i := 1;
- left := 1;
- while i <= length(s) do
- begin
- if s[i] = ' ' then
- begin
- now := copy(s, left, i - left);
- if now = last then
- begin
- delete(s, left, i - left + 1);
- dec(i, length(last));
- left := i;
- end
- else
- inc(i);
- end
- else
- Inc(i);
- end;
- writeln(s);
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement