sample3.pl0

来自「编译器代码」· PL0 代码 · 共 32 行

PL0
32
字号
const bound=30;
var input, count;
procedure guess;
var temp, upper, lower;
procedure locate;

begin
temp:=(upper+lower)/2;
if temp<input then
lower:=temp+1;
if temp>input then
upper:=temp-1;
end;

begin
upper:=bound;
lower:=0;
temp:=(upper+lower)/2;
while temp#input do
begin
count:=count+1;
call locate;
end;
end;

begin
input:=6;
count:=1;
call guess;
write(count);
end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?