program ReverseWords;
const
InputStr = 'python java c c++ pascal';
MaxWords = 10;
var
Words: array[1..MaxWords] of string;
WordCount, i: Integer;
TempStr, OutputStr: string;
begin
// Split the input string into words
TempStr := InputStr;
WordCount := 0;
while Length(TempStr) > 0 do
begin
Inc(WordCount);
Words[WordCount] := Copy(TempStr, 1, Pos(' ', TempStr) - 1);
Delete(TempStr, 1, Pos(' ', TempStr));
if Pos(' ', TempStr) = 0 then
begin
Inc(WordCount);
Words[WordCount] := TempStr;
Break;
end;
end;
// Reverse the words and join them into a single string
OutputStr := '';
for i := WordCount downto 1 do
begin
OutputStr := OutputStr + Words[i];
if i > 1 then
OutputStr := OutputStr + ' ';
end;
WriteLn(OutputStr);
end.
(*
run:
pascal c++ c java python
*)