Var a,b:array[1..10000] of longint;
i,n,d,t:longint;
Begin
{$ifndef online_JUDGE}
Assign(input,'standard.inp');
Reset(input);
Assign(output,'standard.out');
Rewrite(output);
{$endif}
n:=1000; d:=0; t:=0;
While n<>0 do
Begin
Read(n);
If n=0 then Break;
If n<5 then
Begin
inc(d);
a[d]:=n;
end;
end;
For i:=d downto 1 do
Begin
inc(t);
b[t]:=a[i];
end;
For i:=1 to t do
Write(b[i],' ');
end.
Em ko biết viết code bằng Pascal
uses crt;
const fi='dlra.txt'
var a:array[1..10]of integer;
n,i:integer;
f1:text;
begin
clrscr;
assign(f1,fi); rewrite(f1);
repeat
write('Nhap so luong phan tu:'); readln(n);
until (n<=10) and (n>0);
for i:=1 to n do readln(a[i]);
for i:=1 to n do if (a[i]<5) then write(f1,a[i]:4);
close(f1);
end.


