比赛 |
HAOI2009 模拟试题2 |
评测结果 |
WWWWWEEEEE |
题目名称 |
可可的文本编辑器 |
最终得分 |
0 |
用户昵称 |
maxiem |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2009-04-22 09:37:22 |
显示代码纯文本
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:=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);
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;
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.