L
lixiaohui
Unregistered / Unconfirmed
GUEST, unregistred user!
type
p=^integer;
var
MyQueue:TQueue
//声明队变量
MyStack:TStack
//声明栈变量
i,m:integer;
p1,p2;
begin
MyQueue:=TQueue.Create();
{Push部分}
for i:=0 to 10 do
begin
p1:=@i;
MyQueue.Push(p1);
end;
{Pop部分}
for i:=0 to (MyQueue.Count-1) do
begin
p1:=MyQueue.Pop;
m:=p1^;
memo1.Lines.Add(inttostr(m));
end;
memo1.Lines.Add(inttostr(MyQueue.Count));
{释放队的资源}
MyQueue.Free;
MyStack:=TStack.Create();
{Push部分}
for i:=0 to 10 do
begin
p2:=@i;
MyStack.Push(p2);
end;
{Pop部分}
for i:=0 to (MyStack.Count-1) do
begin
p2:=MyStack.Pop;
m:=p2^;
memo1.Lines.Add(inttostr(m));
end;
memo1.Lines.Add(inttostr(MyStack.Count));
MyStack.Free;
end;
p=^integer;
var
MyQueue:TQueue
//声明队变量
MyStack:TStack
//声明栈变量
i,m:integer;
p1,p2;
begin
MyQueue:=TQueue.Create();
{Push部分}
for i:=0 to 10 do
begin
p1:=@i;
MyQueue.Push(p1);
end;
{Pop部分}
for i:=0 to (MyQueue.Count-1) do
begin
p1:=MyQueue.Pop;
m:=p1^;
memo1.Lines.Add(inttostr(m));
end;
memo1.Lines.Add(inttostr(MyQueue.Count));
{释放队的资源}
MyQueue.Free;
MyStack:=TStack.Create();
{Push部分}
for i:=0 to 10 do
begin
p2:=@i;
MyStack.Push(p2);
end;
{Pop部分}
for i:=0 to (MyStack.Count-1) do
begin
p2:=MyStack.Pop;
m:=p2^;
memo1.Lines.Add(inttostr(m));
end;
memo1.Lines.Add(inttostr(MyStack.Count));
MyStack.Free;
end;