Program HOC24;
var i: byte;
st,s: string;
begin
write('Nhap xau: '); readln(s);
while s[length(s)]=#32 do delete(s,length(s),1);
while s[1]=#32 do delete(s,1,1);
while pos(#32,s)<>0 do delete(s,pos(#32,s),1);
for i:=length(s) downto 1 do st:=st+s[i];
write('Xau nguoc lai sau khi da bo het dau cach: ',st);
readln
end.
*Cách khác:
uses crt;
var st:string;
i,d:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
for i:=1 to d do
if st[i]=#32 then delete(st,i,1);
for i:=length(st) downto 1 do
write(st[i]);
readln;
end.