Loops 如何使用Brainfuck中的循环打印从1到10的数字?有可能吗?

Loops 如何使用Brainfuck中的循环打印从1到10的数字?有可能吗?,loops,brainfuck,esoteric-languages,Loops,Brainfuck,Esoteric Languages,如何使用Brainfuck中的循环打印从1到10的数字?甚至可能吗? 我正在寻找解决这个问题的办法 +++++++++++++++++++++++++++++++++++++++++++++++++ Cell 0 to '1' >++++++++++ cell 1 to '\n' >+++++++++ cell 2 to 9 as counter [ Print numbers 1 to 9 << Data pointer to cell 0 .+ Print

如何使用Brainfuck中的循环打印从1到10的数字?甚至可能吗?
我正在寻找解决这个问题的办法

+++++++++++++++++++++++++++++++++++++++++++++++++  Cell 0 to '1'
>++++++++++  cell 1 to '\n'
>+++++++++  cell 2 to 9 as counter
[  Print numbers 1 to 9
<<  Data pointer to cell 0
.+  Print and increment cell 0
>.  Data pointer to cell 1 and print the newline
>-  Data pointer to cell 2 and decrement counter
]  Loop till counter is 0
+++++++++  Set cell 2 to 9
[  Set cell 0 to '1'
<<-  Data pointer to cell 0 and decrement
>>-  Data pointer to cell 2 and decrement counter
]  Loop till counter is 0
<<.  Data pointer to cell 0 and print '1'
-.   Decrement cell 0 and print '0'
>.   Data pointer to cell 1 and print newline
现场演示:

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++让地址0成为我们要打印的数字,从“0”开始
>++++++++++让地址1成为我们的换行符
>+++++++++让地址2作为我们的柜台,从9点开始
[
-减量计数器
在我们回圈之前,确保我们又到了柜台
]
TL;DR

-[>+<-----]>---<++++++++++<++++++++++[>>.+<.<-]>>---------.-.
但是,最后两个步骤可以简化为:

Go back to the digit '9'
Decrement it until '1' and print
Decrement it until '0' and print
这样可以节省大量时间和字节字符

要生成字符“0”,需要生成整数48(因为它是ASCII值)。要做到这一点,你可以去。查找数字48,我们发现
-[>+-

到目前为止,我们的程序是生成
0


接下来,向左移动并生成
\n
(换行符)。我们可以使用
+--这是可能的。下面是代码:
++++>++++++++++[>++-.+.+.+.+.+.+.+.+.+.+.------------.
它可以更短,但是,它仍然完成相同的任务。Brainf***理论上可以执行任何计算,因为它是图灵完成的。这只是其中的一种计算。

我已经搜索了这么长时间,还没有发现任何以这种方式在Brainfack中使用循环的例子Brainf**k图灵是完全的,所以是的,这是可能的。
++++++++++++++++++++++++++++++++++++++++++++++++ Let address 0 be the digit we want to print, starting with '0'
>++++++++++ Let address 1 be our newline character
>+++++++++ Let address 2 be our counter, starting at 9 
[
  - Decrement the counter
  <<+. Increment the digit we want to print and print it
  >. Print the newline
  > Make sure we're at the counter again before we loop back
]

<< Move back to address 0
--------. Make address 0 '1'
-. Make address 0 '0'
-[>+<-----]>---<++++++++++<++++++++++[>>.+<.<-]>>---------.-.
Generate the character '0'
Move left and generate '\n'
Move left and generate the counter (10 numbers in this case)
Loop: Get back to the character '0', print it, increment it to '1', go to the newline, print it, go to the counter, and decrement it. End it when the counter is 0
Generate '1' and print it
Generate '0' and print it
Go back to the digit '9'
Decrement it until '1' and print
Decrement it until '0' and print