27-11-2004, 19:35
|
|
|
|
חבר מתאריך: 07.01.03
הודעות: 101
|
|
הנה גם "איבר בעומק מחסנית" לכל המעוניין
program deep2;
uses stack;
var
st1:stack_type;
k2:integer;
temp:stack_info_type;
procedure deep(st:stack_type; k:integer; var tp:stack_info_type);
var
st2:stack_type;
i:integer;
temp:stack_info_type;
begin
k:=k-1;
for i:=1 to k do
begin
stack_pop(st,temp);
stack_push(st2,temp);
end;
stack_top(st,tp);
end;
{---------------}
begin
writeln('please enter the stack');
readln(temp);
while temp<>'*' do
begin
stack_push(st1,temp);
readln(temp);
end;
writeln('please enter the deepness');
readln(k2);
deep(st1,k2,temp);
writeln;
if st1.top<k2 then
temp:=' ';
writeln('the item is:' ,temp);
end.
|