Pascal 致命:语法错误;期待,但是。建立

Pascal 致命:语法错误;期待,但是。建立,pascal,Pascal,这是一个关于冒险的迷你游戏。而且,程序无法显示预期的答案。pascal抛出的错误是:致命:语法错误;期待,但是。建立我想也许我的逻辑是错的。谢谢;) 你错过了两个“结束;”声明。我已重新格式化以显示问题(和解决方案) 如果语句未对齐,的块结构。检查所有开始和结束对。代码非常奇怪,因为如果guess=1或guess=2,它会不断重新检查。您有两个end语句位于具有begin的块中。如果您学会正确地缩进代码,那么代码缺失的地方将显而易见。每次使用begin都需要有一个相应的end。在if-else的

这是一个关于冒险的迷你游戏。而且,程序无法显示预期的答案。pascal抛出的错误是:致命:语法错误;期待,但是。建立我想也许我的逻辑是错的。谢谢;)

你错过了两个“结束;”声明。我已重新格式化以显示问题(和解决方案)


如果语句未对齐,
的块结构。检查所有
开始
结束
对。代码非常奇怪,因为如果
guess=1
guess=2
,它会不断重新检查。您有两个
end语句位于具有
begin
的块中。如果您学会正确地缩进代码,那么代码缺失的地方将显而易见。每次使用
begin
都需要有一个相应的
end
。在if-else的if语句末尾,不应该有
program Adventure;
uses Crt;
var
   guess : integer ;
   begin
   TextColor(White);
   TextBackground(Green);
   writeln('Adventure');
   writeln('You are an adventurer. You are having an adventure in the forrest but you get lost in the way. You need to answer questions to escape from the forrest.');
   writeln('The game will start now.');

   writeln('Question1: You are hungry now. You find a mushroom. Will you eat it?');
   writeln('Press ',1,'=yes, ',2,'=no.');
   readln(guess);

   if guess = 1 then
        begin
        {condition 1}
        writeln('It is a toxic mushroom. You died.');
        writeln('This is the end of the game.');
        readln;
        end

   else if guess = 2 then
   begin
        {condition 2}
        writeln('You do not eat the mushroom but you catch some fishes in the river.');
        writeln('You are full now and have energy to find the way to escape frome forest.');
        writeln('Question2:You see a bear and it keeps follow you. Will you climb up to a tree?');
        writeln('Press ',1,'=yes, ',2,'=no.');
        readln(guess);

   if guess = 2 then
   begin
        {condition 1}
        writeln('You are killed by the bear.');
        writeln('This is the end of the game.');
        readln;
   end

   else if guess = 1 then
   begin
        {condition 2}
        writeln('You escape from the bear.');
        writeln('Question3:Will you get in the cave?');
        writeln('Press ',1,'=yes, ',2,'=no.');
        readln(guess);
        readln;

   if guess = 1 then
   begin
        {condition 1}
        writeln('You are killed by the lion which live in the cave');
        writeln('This is the end of the game.');
        readln;
   end

   else if guess = 2 then
   begin
        {condition 2}
        writeln('Although you get wet, but you find the way to escape from the forrest finally.');
        writeln('Congratulations!');
        writeln('This is the end of the game.');
        readln;
   end;
end.
 program Adventure;
 uses Crt;
 var
    guess : integer ;
 begin
    TextColor(White);
    TextBackground(Green);
    writeln('Adventure');
    writeln('You are an adventurer. You are having an adventure in the forrest but you get lost in the way. You need to answer questions to escape from the forrest.');
    writeln('The game will start now.');

    writeln('Question1: You are hungry now. You find a mushroom. Will you eat it?');
    writeln('Press ',1,'=yes, ',2,'=no.');
    readln(guess);

    if guess = 1 then
    begin
       {condition 1}
       writeln('It is a toxic mushroom. You died.');
       writeln('This is the end of the game.');
       readln;
    end

    else if guess = 2 then
    begin
       {condition 2}
       writeln('You do not eat the mushroom but you catch some fishes in the river.');
       writeln('You are full now and have energy to find the way to escape frome forest.');
       writeln('Question2:You see a bear and it keeps follow you. Will you climb up to a tree?');
       writeln('Press ',1,'=yes, ',2,'=no.');
       readln(guess);

       if guess = 2 then
       begin
          {condition 1}
          writeln('You are killed by the bear.');
          writeln('This is the end of the game.');
          readln;
       end

       else if guess = 1 then
       begin
          {condition 2}
          writeln('You escape from the bear.');
          writeln('Question3:Will you get in the cave?');
          writeln('Press ',1,'=yes, ',2,'=no.');
          readln(guess);
          readln;

          if guess = 1 then
          begin
             {condition 1}
             writeln('You are killed by the lion which live in the cave');
             writeln('This is the end of the game.');
             readln;
          end

          else if guess = 2 then
          begin
             {condition 2}
             writeln('Although you get wet, but you find the way to escape from the forrest finally.');
             writeln('Congratulations!');
             writeln('This is the end of the game.');
             readln;
          end;
       end;
    end;
 end.