记录编号 811 评测结果 AAAAAA
题目名称 队列基本操作 最终得分 60
用户昵称 GravatarOo湼鞶oO 是否通过 通过
代码语言 Pascal 运行时间 10.000 s
提交时间 2008-07-22 15:12:03 内存使用 0.00 MiB
显示代码纯文本
{*******************************************}
{* Program Name:queue                      *}
{* Input file:queue.in                     *}
{* Output file:queue.out                   *}
{* Date:2008.7.22                          *}
{* Programmer:Peng Bo                      *}
{*******************************************}
program queue;
type
  dl=array[1..10]of longint;
var
  i,o:text;
  s:dl;
  n:word;
  l:byte;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure dl2;
var
  t:longint;
begin
  readln(i,t);
  if l<11
  then
  begin
    s[l]:=t;
    inc(l);
  end
  else
    writeln(o,'queue out');
end;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure dl3;
var
  j:byte;
begin
  if l>1
  then
  begin
    if l>2
    then
      for j:=1 to l-2 do
        s[j]:=s[j+1];
    dec(l);
  end
  else
    writeln(o,'queue empty');
end;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure dl4;
var
  j:byte;
begin
  writeln(o,l-1);
  for j:=1 to l-1 do
    write(o,s[j],' ');
  writeln(o);
end;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure fileb;
begin
  assign(i,'queue.in');
  reset(i);
  readln(i,n);
  assign(o,'queue.out');
  rewrite(o);
end;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure filef;
begin
  close(i);
  close(o);
end;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure main;
var
  j:word;
  f:byte;
begin
  for j:=1 to n do
  begin
    read(i,f);
    case f of
      1:l:=1;
      2:dl2;
      3:dl3;
      4:dl4;
    end;
  end;
end;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
begin
  l:=1;
  fileb;
  main;
  filef;
end.
{End.}