我在书上看见有一段代码如下
if J<>0 then 
begin
   Result:=I/J;
   Count:=Count+1;
end
else if Count=last than
   done:=True
else
   exit
请问在True后需要分号吗?教材上没有,是不是每一个语句后都要用分号,请给我详细说明一下,好吗?

解决方案 »

  1.   

    不要分号。在else  上面的一条语句都不要分号如
    if j <> 0 then
    begin
      ...
    end
    else beginend; //这个要因为下面没有else
    if j =0 then
    begin
    end
    else if j > 0 then 
    begin
    end  //这个不要下面又else
    else if j < 0 then 
    begin
    end;
      

  2.   

    up
    delphi和c不同,只是在分号不是语句的一部分,只是语句之间的间隔用,也就是两个语句之间和整个结束是才用
      

  3.   

    在pascla中分号表示一个语句的结束。而判断语句有两种可能,如在then后加了分号,则表示结束,对假的情况不做处理
      

  4.   

    if ... then后面跟着一个语句statement1statement1可以是begin end块,也可以是简单语句如done:=True
    当if ... then statement1 后面要接else时
    statement1后面不能有语句终结符 -- 分号
    如果没有接else,则必须有分号