Advertisement
MadCortez

Untitled

Apr 19th, 2021
685
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.58 KB | None | 0 0
  1. var
  2.    s, last, now: string;
  3.    i, left: Integer;
  4. begin
  5.    Readln(s);
  6.    i := length(s);
  7.    while s[i] <> ' ' do
  8.       dec(i);
  9.    last := copy(s, i + 1, length(s) - i + 1);
  10.    i := 1;
  11.    left := 1;
  12.    while i <= length(s) do
  13.    begin
  14.       if s[i] = ' ' then
  15.       begin
  16.          now := copy(s, left, i - left);
  17.          if now = last then
  18.          begin
  19.             delete(s, left, i - left + 1);
  20.             dec(i, length(last));
  21.             left := i;
  22.          end
  23.          else
  24.             inc(i);
  25.       end
  26.       else
  27.          Inc(i);
  28.    end;
  29.    writeln(s);
  30. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement