【问题标题】:pascal syntax error ; expected but . found?帕斯卡语法错误;预期但是。成立?
【发布时间】:2012-11-18 20:02:34
【问题描述】:
program MouseInput;
Uses WinCrt,WinMouse, Graph;
Var GraphicsDriver, GraphicsMode :smallint;
x, y: smallint;
function GetMouseX: word;
function GetMouseY: word;
procedure InitMouse;
procedure DoneMouse;
Begin
     Writeln('Initialising Graphics, please wait...');
     GraphicsDriver := Detect;
     InitGraph(GraphicsDriver, GraphicsMode,'');
     begin
          InitMouse;
          Writeln('Move mouse cursor to square 10,10 to end');
          Repeat
                X:=GetMouseX;
                Y:=GetMouseY;
                Writeln('X,Y= (',X,',',Y,')');
          Until (X=9) and (Y=9);
          DoneMouse;
     end;
end.

帕斯卡抛出的错误是: 23 / 4 鼠标.pas 致命:语法错误,;预期但是。成立 但我有正确的开始和结束数量,所以它是最后一个需要'。'

一切顺利 安排

【问题讨论】:

    标签: syntax syntax-error pascal


    【解决方案1】:

    您缺少主程序块,然后您的某些功能程序当然也一样。下面的代码将在提供缺失的块时进行编译,但它当然什么也不做。

    program MouseInput;
    Uses WinCrt,WinMouse, Graph;
    Var GraphicsDriver, GraphicsMode :smallint;
    x, y: smallint;
    
    function GetMouseX: word;
    begin
    end;
    function GetMouseY: word;
    begin
    end;
    procedure InitMouse;
    begin
    end;
    
    procedure DoneMouse;
    Begin
         Writeln('Initialising Graphics, please wait...');
         GraphicsDriver := Detect;
         InitGraph(GraphicsDriver, GraphicsMode,'');
         begin
              InitMouse;
              Writeln('Move mouse cursor to square 10,10 to end');
              Repeat
                    X:=GetMouseX;
                    Y:=GetMouseY;
                    Writeln('X,Y= (',X,',',Y,')');
              Until (X=9) and (Y=9);
              DoneMouse;
         end;
    end;
    
    begin
    end.
    

    【讨论】:

    • 我把它改成了那个,我得到了和以前一样的错误。 (显然有两个函数错误)
    • @Arran - 抱歉,有一个点而不是半列,请重试。
    • 现在运行的干杯。 :) 我如何让我的功能和程序工作?我最近才开始学习帕斯卡,所以请像我一样愚蠢地跟我说话。一切顺利
    • @Arran - 主块中的代码是执行的。所以你把代码放在那里可能会调用其他程序等。但我不能真正让你开始使用 pascal,你需要一本书或类似的文档。 :) 顺便说一句,如果 accepting 回答了您的问题,请考虑答案。
    【解决方案2】:
    Function monotone(
        A : Int_Array; {array [1..20] of integer}
        n : integer ) {size of the defined lower}
          : integer ; {portion of A}
    
    VAR
    i, {index for current limseq}
    j, {index for predecessors of current limseq}
    maxj, {length of current longest predecessors subsequence}
    pmax, {end of current limseq inA[1..i-1]}
    curr, {=A[i]}
    maxl : integer; {length of limseq ending at pmax}
    length : Int_Array; {length [k] is the length of}
                        {limseq at k}
        begin {monotone}
            {<STAD> Initialization of parameter A}
            {<STAD> Initialization of parameter n}
            length[1]:=1;
            pmax:=1;
            maxl:=1;
            i:=2;
            while i<=n do
            begin
                curr:=A[1];
                if curr<A[pmax} then
                    begin
                        max j:=1;
                        j:=1;
                        while j<={i-1} do
                            begin 
                                if A[j]<curr then
                                    begin
                                        if maxj<length[j] then
                                           maxj:=length[j];
                                    end;
                                j:=j+1;
                            end;
                        length[i]:=maxj+1;
                        if length [i]>maxl+1;
                        pmax:=i;
                    end;
                end   
            ELSE {if curr<A[pmax]}
                begin
                    maxl:=maxl+1;
                    length[i]:=maxl;
                    pmax:=i;
                end;
    
            monotone:=maxl;
            {<STAD> EXIT USE OF monotone (FUNCTION RESULT)}
            end; {monotone}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-02-03
      • 1970-01-01
      • 1970-01-01
      • 2015-03-23
      • 1970-01-01
      • 2011-05-21
      • 1970-01-01
      相关资源
      最近更新 更多