我真的很感兴趣 - 你为什么需要把
readln;
从键盘读取一些值到变量后的行?例如,
repeat
writeln('Make your choise');
read(CH);
if (CH = '1') then begin
writeln('1');
end;
{ ... }
until CH = 'q';
如果您运行以下代码,然后在键盘上按“1”,您会得到类似的输出
1
Make your choise
Make your choise
Make your choise
另一方面,如果您添加“readln;” 行,一切都很完美:
repeat
writeln('Make your choise');
read(CH);
readln;
if (CH = '1') then begin
Writeln('1');
end
until CH = 'q';
我唯一的猜测是不带参数调用readln 会终止读取键盘输入的过程。但如果是这样,为什么 read/readln 函数不能自己停止读取输入,以避免这种笨拙?