关于PASCAL中的GOTO语句问题

2025-04-07 04:30:32
推荐回答(1个)
回答1:

你的代码层次太乱,调整如下:
program kids;
label  1,2,3,4,5,6,7,8,9,10,11,12;
var 
b,e,f,n,c,d,min,max:integer;
h,i:real;
     a,t:char;
begin
4: writeln('what kind of math do you want to do ?');
writeln('a addition');
writeln('b subtraction');
writeln('c multiplication');
writeln('d division');
writeln('e arithmetics');
writeln('f equation');
writeln('g exit');
writeln;
read(a);
readln;
if a='a' then begin
write('which level do you want to choose?(1-3)');
writeln;
read(b);
if b=1 then begin
1: n:=0;
for f:=1 to 10 do begin
  randomize;
     c:=random(10);
     d:=random(10);
    write(c,'+',d,'=?');
    writeln;
    readln(e);
    if e=c+d then begin
    write ('good!');n:=n+10;end
    else write('sorry,try again ^ ^');
    writeln;
    end;
    if n>90 then begin
    write ('congratulations!you can choose a higher level,do you want to do on?(y/n)');
    read(t);
    if t='y' then goto 2;
    end
    else begin 
write('sorry,you need do more exercise,do you want to go on?(y/n)');
    writeln;
     read(t);
    if t='y' then goto 1 else goto 4;
    end;
end;
end;
2:
end.