Pascal中的双“ else”语句

德米特里·鲁缅采夫(Dmitry Rumyantsev)

当我偶然发现有问题的“其他”构造时,我试图将以下Pascal代码转换为C ++。我以前从未见过,所以有人可以告诉我它的功能以及C ++(或C)的等效功能是什么吗?

  Procedure Force(Q:Int64;V,K:Integer);
   Var i,j,t:Integer;
    begin
     if K<=0 then
      if (Q>=A)and(Q Mod KK =0)and(V>=S)and(V<=F)then Out:=Out+1 else else
       For i:=0 to 9 do
        if (Q+(i+1)*h[k-1]>=A)and(Q+i*h[k-1]<=B) then
         if (Q+(i+1)*h[K-1]<B)and(Q+i*h[k-1]>=A) then
          Begin
           M:=(Q+i*h[k-1]) Mod KK;
           For j:=0 to 9*(K-1) do
            For t:=0 to KK-1 do
             if D[K-1,j,t]>0 then
              if (V+i+j>=S)and(V+i+j<=F)and((t+M) Mod KK=0) then
                 Out:=Out+D[K-1,j,t];
           end else
            if Odd(N-K+1) then Force(Q+i*h[k-1],V+i,K-1) else
                               Force(Q+i*h[k-1],V+i,K-1);
    end;
塞尔吉奥

我刚刚复制到一个编辑器(例如,Komodo,您可以在其中选择Pascal作为语法颜色突出显示的语言),并以我自己可以阅读的方式重新格式化您编写的文本。

procedure Force(Q:Int64;V,K:Integer);
var 
  i,j,t:Integer;
begin
  if K<=0 then
    if (Q>=A) and (Q Mod KK =0) and (V>=S) and (V<=F) then
      Out:=Out+1
    else
  else
    for i:=0 to 9 do begin
      if (Q+(i+1)*h[k-1]>=A) and (Q+i*h[k-1] <= B) then
        if (Q+(i+1)*h[K-1]<B) and (Q+i*h[k-1] >= A) then begin
          M := (Q+i*h[k-1]) Mod KK;
          for j:=0 to 9*(K-1) do begin
            for t:=0 to KK-1 do begin
              if D[K-1,j,t] > 0 then
                if (V+i+j >= S) and (V+i+j <= F) and ((t+M) mod KK = 0) then
                  Out:=Out+D[K-1,j,t];
            end; {for t}
          end; {for j}
        end else
          if Odd(N-K+1) then
            Force(Q+i*h[k-1],V+i,K-1)
          else
            Force(Q+i*h[k-1],V+i,K-1);
      end;
    end;
end;

您不觉得现在更容易理解了吗?

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章