我的 Pascal 程序在主 begin语句和 4 个程序中有一个菜单。在每个程序中,我都会向用户确认他们是否要返回菜单,否则程序将退出,但是每次程序要退出时,它都会再次返回菜单。
procedure quit;
begin
writeln('<Enter> to quit...');
readln;
end
procedure error;
begin
writeln('Error. Try Again...');
readln;
end;
procedure option1;
begin
clrscr;
writeln('this is option 1');
writeln('would you like to continue? (y/n)');
readln(confirm);
if confirm = 'y' then
begin
writeln('something will happen...');
end;
if confirm = 'n' then
begin
writeln('Return to main menu ? (y/n)');
readln(option);
if option = 'y' then
exit
else
quit;
end;
end;
procedure option2;
begin
clrscr;
writeln('this is option2');
writeln('would …Run Code Online (Sandbox Code Playgroud)