📄 stack1.pas
字号:
program E1_2; {stack_count1}
var count:longint;
n,i,top,head:integer;
a:array[1..100] of byte;
input,output:text;
procedure init;
begin
assign(input,'stack1.in'); reset(input);
readln(input,n); close(input);
for i:=1 to n do a[i]:=0;
head:=1; top:=0
end;
procedure push;
begin inc(top); a[top]:=head; inc(head) end;
procedure pop;
begin a[top]:=0; dec(top) end;
procedure work;
var j,k:byte;
begin
if (top=0) and (head=n+1) then inc(count)
else
for j:=1 to 2 do
begin
if (j=2) and (top>0) then
begin
k:=a[top];
pop;
work;
inc(top);
a[top]:=k;
end;
if (j=1) and (head<n+1) then
begin
push;
work;
dec(top);
dec(head);
end;
end
end;
procedure print;
begin
assign(output,'stack1.out'); rewrite(output);
writeln(output,count); close(output)
end;
begin
init; work; print
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -