显示代码纯文本
program editor;
var
o,s,tmp:ansistring;
point,i,n:longint;
code:integer;
procedure ins;
var a,l:longint;
begin
val(copy (o,pos(' ',o)+1,length(o)-pos(' ',o)),l,code);
readln (tmp);
s:=copy(s,1,point)+tmp+copy(s,point+1,length(s)-point);
end;
procedure mov;
var l:longint;
begin
val(copy (o,pos(' ',o)+1,length(o)-pos(' ',o)),l,code);
if l<>0 then point:=l else point:=0;
end;
procedure del;
var l:longint;
begin
val(copy (o,pos(' ',o)+1,length(o)-pos(' ',o)),l,code);
delete (s,point+1,l);
end;
procedure rot;
var i,l:longint;
begin
tmp:='';
val(copy (o,pos(' ',o)+1,length(o)-pos(' ',o)),l,code);
if l<>1 then begin
for i:=point+l downto point+1 do tmp:=tmp+s[i];
for i:=point+1 to point+l do s[i]:=tmp[i-point];
end;
end;
begin
s:='';
assign (input,'editor.in');
reset (input);
assign (output,'editor.out');
rewrite (output);
readln (n);point:=0;
for i:=1 to n do begin
readln (o);
if copy(o,1,6)='Insert' then ins;
if copy(o,1,4)='Move' then mov;
if copy(o,1,6)='Delete' then del;
if copy(o,1,4)='Next' then inc(point);
if copy(o,1,4)='Prev' then dec(point);
if copy(o,1,6)='Rotate' then rot;
if copy(o,1,3)='Get' then writeln(s[point+1]);
end;
close (input);
close (output);
end.