program Chuchay;uses crt; {khai bao thu vien}
var s:string; { bat dau khai bao bien}
i:byte;
dung,stop:boolean;
begin {bat dau CT chinh}
writeln(' nhap vao chu ban muon:'); { nhap vao chu chay tren man hinh}
readln(s);
i:=1; { gan gia tri ban dau chi bien i}
dung:=true; {gan gia tri ban dau chi 2 bien logic de co the dung CT va dao chieu chay}
stop:false;
clrscr; {xoa man hinh}
repeat { bat dau vong lap repeat}
while (i<75-length(s)) and ( not dung) and (not stop) do {neu i<75-(do lai xau vua nhap) va ko Dung}
begin {bat dau vong lap while}
stop:=keypressed; { khi nhan 1 phim bat ki Stop se dc gan Gia tri true}
gotoxy(1,10); {dua con tro den vi tri co toa do (1,10)}
write(' ':i,s); { viet xau s va moi lan viet them 1 khoang trang trc S}
delay(50); {dung lam viec 50/1000s}
inc(i); {i:=i+1}; {tang bien i 1 don vi}
if i>75-length(s) do dung:=false; {neu i>75-(do dai xau vua nhap thi gan gia tri false}
end;
while (i>=1) and dung and (not stop) do { vong lap nay co tac dung doi chieu chay cua xau}
begin
stop:=keypressed;
gotoxy(1,10);
write(s:i);
delay(50);
dec(i); {i:=i-1}; {tru di bien i 1 don vi}
if i<=1 then dung:=true;
end;
until stop; { den khi stop=true thi dung CT}
end. { ket thuc CT chinh}