嗯,我从没听说过这个教学资源叫^{},它是基于网络的OAMulator(1,2,3),它支持OAMPL(OAM编程语言)并(编译)为OAM Assembly。在
所以我作弊了。
首先,我“解析”了您的python代码(我也不懂python),并将其翻译成OAMPL:PRINT "Please enter the number of test scores to be entered:"
READ numberofscores
sumofscores = 0
LOOP numberofscores
PRINT "Please enter the test score:"
READ testscore
sumofscores = (+ sumofscores testscore)
END
PRINT "the answer is:"
PRINT (/ sumofscores numberofscores)
EXIT
注意:我没有翻译你的float,因为它应该是一个int(尽管每个分数可以是一个浮点数)。经过一些测试后,我发现2.5的输入无论如何都是以浮点形式“读取”的。我还丢弃了count变量(因为LOOP指令没有它也可以工作)和average变量(因为我不需要它)。。。
单击compile将呈现(这可能是您的答案):
^{pr2}$
给定input (one per line):
^{3}$
注意:对要求测试分数的问题回答“3”,然后对要求单个测试分数的问题回答“71.4”、“33”和“21.6”。(这不是交互式输入,让我在15分钟内。。。合并^{})
如果我execute以上OAM程序集(编译后!!)输入上述输入,输出呈现:Please enter the number of test scores to be entered:
Please enter the test score:
Please enter the test score:
Please enter the test score:
the answer is:
42
。。。天哪。。答案是42,这是所有事情的答案…
(太酷了。。没有可用的文档,猜测一种编程语言。。。这是我回答过的最酷的问题)
希望这有帮助!在
PS:请在下面的注释中添加指向此OAMPL和OAM程序集的文档/语法的链接!!!在线文档的(1,2,3)我发现没有真正的帮助(例如,WRITE来自“hello world”示例的WRITE没有起作用。。除了cheat-sheet found here)之外,我不知道OAMPL支持什么语法。在