You are on page 1of 1

uses crt;

var F,G:Text; Cif,N,I,Cod:Integer; Ch,P:Char;


begin
assign(F,'robot3.in'); Reset(F); Assign(G,'robot3.out'); rewrite(G);
Cif:=0;
While not Eof(F) do begin read(F,Ch);
If Ch='A' then Write(G,Cif)
else
if Ch<>'T' then begin
read(F,P); Val(P,N,Cod);
if Ch='D' then for I:=1 To N Do
if Cif<9 then Inc(Cif)
else Cif:=0
else for I:=1 to N do
If Cif>0 then Dec(Cif)
else Cif:=9
end;
end;
close(F);
close(G);
end.

You might also like