Anonymous user
Reverse the order of lines in a text file while preserving the contents of each line: Difference between revisions
Reverse the order of lines in a text file while preserving the contents of each line (view source)
Revision as of 18:03, 4 August 2021
, 2 years ago→{{header|Perl}}: prepend pascal
No edit summary |
(→{{header|Perl}}: prepend pascal) |
||
Line 144:
"Diplomacy is the art of
>>>>></pre>
=={{header|Pascal}}==
{{works with|Free Pascal}} maybe {{works with|Delphi}}
<lang pascal>program TAC;
{$IFDEF FPC}
{$MODE DELPHI}
{$ELSE}
{$APPTYPE CONSOLE}
{$ENDIF}
uses
sysutils, classes;
var
Sl:TStringList;
i,j : nativeInt;
begin
Sl := TStringList.Create;
Sl.Loadfromfile('Rodgers.txt');
i := 0;
j := Sl.Count-1;
While i<j do
Begin
Sl.Exchange(i,j);
inc(i);
dec(j);
end;
writeln(Sl.text);
end.</lang>{{out}}
<pre> --- Will Rodgers
until you can find a rock."
saying 'Nice Doggy'
"Diplomacy is the art of</pre>
=={{header|Perl}}==
|