我正在ArnoldC中实现99瓶啤酒的实现,以在Rosetta Code中列出。我希望获取应该在同一行上的整数和字符串以在同一行上打印,但是我无法这样做。整数和字符串可以在ArnoldC中连接吗?如果是这样,那怎么实现?
通过反复试验,我尝试了:
这是我的代码:
IT'S SHOWTIME
HEY CHRISTMAS TREE is0
YOU SET US UP @NO PROBLEMO
HEY CHRISTMAS TREE bottles
YOU SET US UP 99
STICK AROUND is0
TALK TO THE HAND bottles
TALK TO THE HAND "bottles of beer on the wall"
TALK TO THE HAND bottles
TALK TO THE HAND "bottles of beer"
TALK TO THE HAND "Take one down, pass it around"
GET TO THE CHOPPER bottles
HERE IS MY INVITATION bottles
GET DOWN 1
ENOUGH TALK
TALK TO THE HAND bottles
TALK TO THE HAND "bottles of beer on the wall"
GET TO THE CHOPPER is0
HERE IS MY INVITATION bottles
LET OFF SOME STEAM BENNET 0
ENOUGH TALK
CHILL
YOU HAVE BEEN TERMINATED
例如,我想要:
99
bottles of beer on the wall
改为打印为
99 bottles of beer on the wall
但是任何尝试都会导致我收到语法错误。例如,当我尝试向手说一瓶“ \ n墙上有几瓶啤酒”时,我得到:
线程“ main” org.parboiled.errors.ParsingException中的异常: 我该怎么办:
无效的输入“”,预期A..Z, a..z,0..9,'\ t','\ r',''或'\ n'(第7行,pos 25):
与 手动瓶“ \ n在墙上的啤酒瓶” ^
在org.arnoldc.ArnoldParser.parse中的(ArnoldParser.scala:203)
at org.arnoldc.ArnoldGenerator.generate(ArnoldGenerator.scala:10)
at org.arnoldc.ArnoldC $ .main(ArnoldC.scala:21)
at org.arnoldc.ArnoldC.main(ArnoldC.scala)
错误:找不到或 加载主类代码
如果您认为我很奇怪地格式化了这个问题中的任何一个,请原谅,我找不到如何格式化它的格式,以免我想要的每一行之间没有空白行。
顺便说一句,我正在使用https://tio.run/#arnoldc运行我的代码。