算法:队列
很简单的一个队列操作。
很简单的一个队列操作。
I命令是向队尾追加一个元素,O命令是输出队头元素并且队头出队。
program P1133;
var
x,tail,head:longint;
que:array [1..100] of longint;
ch:char;
begin
assign(input,'P1133.in'); reset(input);
assign(output,'P1133.out'); rewrite(output);
fillchar(que,sizeof(que),0);
head:=1;
tail:=0;
while not eof do
begin
read(ch);
if ch='O' then
begin
if tail<head then writeln('None')
else
begin
writeln(que[head]);
inc(head);
end;
end;
if ch='I' then
begin
readln(x);
inc(tail);
que[tail]:=x;
end;
end;
close(input); close(output);
end.