program ReverseWords;
uses SysUtils;
varsentence, reversedSentence: string;words: TStringList;i: integer;
beginwriteln('Введите предложение:');readln(sentence);
words := TStringList.Create;words.Delimiter := ' ';words.DelimitedText := sentence;
reversedSentence := '';
for i := words.Count - 1 downto 0 dobeginreversedSentence := reversedSentence + words[i] + ' ';end;
writeln('Слова в обратном порядке:');writeln(Trim(reversedSentence));end.
program ReverseWords;
uses SysUtils;
var
sentence, reversedSentence: string;
words: TStringList;
i: integer;
begin
writeln('Введите предложение:');
readln(sentence);
words := TStringList.Create;
words.Delimiter := ' ';
words.DelimitedText := sentence;
reversedSentence := '';
for i := words.Count - 1 downto 0 do
begin
reversedSentence := reversedSentence + words[i] + ' ';
end;
writeln('Слова в обратном порядке:');
writeln(Trim(reversedSentence));
end.