gpt4 book ai didi

if-statement - 为什么不评估此 Cobol 代码中的第二个 if 语句 (OpenCOBOL)?

转载 作者:行者123 更新时间:2023-12-04 05:04:14 26 4
gpt4 key购买 nike

   identification division.
program-id. quick.
environment division.
data division.
working-storage section.
01 temp-val1 pic 9 value 1.
01 temp-val2 pic 9 value 2.
procedure division.
mainline.
perform encrypt.
stop run.
encrypt.
if (temp-val1 = 1)
display "1"
display "2".
end_if.
if (temp-val2 = 2)
display "2"
display "1".
end_if.
display "outside the ifs".

程序的输出很简单:
1
2

但我希望:

1
2
2
1
在ifs之外

我做错了什么?我是否误解了第一个 if 内语句的句子结构或句点的位置?

最佳答案

代码有两个问题。一个是 end-if 之前的句点。

另一个是end_ifend-if是不一样的。 Cobol 中仅使用 end-ifend_if 被当作段落名称。因此,它不会(也不应该)产生编译器警告消息。

关于if-statement - 为什么不评估此 Cobol 代码中的第二个 if 语句 (OpenCOBOL)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16068385/

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