Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PASCAL错误:直到预期,但找到结束_Pascal - Fatal编程技术网

PASCAL错误:直到预期,但找到结束

PASCAL错误:直到预期,但找到结束,pascal,Pascal,我的pascal代码有问题 编译时,它向我显示错误:syntax:until-expected-but-end-find PROGRAM EvilGOTO; Var rand,count,guess : integer; LABEL correct, schleife, wrong, ende; begin Randomize; count :=0; repeat schleife:

我的pascal代码有问题

编译时,它向我显示错误:syntax:until-expected-but-end-find

PROGRAM EvilGOTO;
Var rand,count,guess : integer;
LABEL correct, schleife, wrong, ende;

begin
    Randomize;
            count :=0;
            repeat
                    schleife:
                    count := count+1;
                    rand := Random(10);
                    guess := Random(10);
                    if rand=guess
                    then
                            writeln('Correct')
                            end
                    else
                            writeln('False Guess')
                            goto schleife
             until
             count = 10;
end.    

你能帮我吗?

如果..那么..结束是个问题。在
writeln('Correct')
之后的
end
。最好避免
goto
。试着想出另一种退出循环的方法。旁注:您似乎在使用
goto
创建循环,但您正在循环中使用它(
重复…直到
)。这完全是多余的,当你解决了@TLama提到的问题后,你可以试着去掉
goto
(以及相应的标签)。你能帮我优化这个代码吗?:)好的,非常感谢,但是程序必须在“正确”后停止。我怎样才能得到这个函数?现在它在10个“正确”值后停止。是否要在第一个错误值之后停止?程序显示的错误值不应超过10个,如果一个错误值正确,则必须停止/结束。@我无法从代码中猜到这一点:)已更改。但现在他得到了布尔值,但预期为int64:D
PROGRAM EvilGOTO;
Var rand,count,guess : integer;
begin
    Randomize;
    count :=0;
    repeat
      rand := Random(10);
      guess := Random(10);
      if rand=guess then
         writeln('Correct')
         else
         begin
           count := count+1;
           writeln('False Guess');
         end
    until count = 10 or rand=guess;
end.