gpt4 book ai didi

c++ - Pascal 中的双 'else' 语句

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:51:33 25 4
gpt4 key购买 nike

当我偶然发现有问题的“else else”结构时,我试图将以下 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;

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

关于c++ - Pascal 中的双 'else' 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37166486/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com