program RemoveLastWord;
uses
SysUtils; // LastDelimiter
const
InputStr = 'c# rust c c++ java pascal';
function RemoveLast(s: string): string;
var
LastSpacePos: Integer;
begin
LastSpacePos := LastDelimiter(' ', s);
if LastSpacePos > 0 then
RemoveLast := Copy(s, 1, LastSpacePos - 1)
else
RemoveLast := s;
end;
begin
WriteLn(RemoveLast(InputStr));
end.
(*
run:
c# rust c c++ java
*)