Brainfuck 中两个一位数字相乘的代码
有人可以发布一个用编程语言 Brainf*ck 来乘以两个一位数的代码吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
有人可以发布一个用编程语言 Brainf*ck 来乘以两个一位数的代码吗?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(9)
程序读取单元格 #1、#2,结果将出现在单元格 #3 中
我使用 BF 解释器,可以将数字输入为数字(不是 ASCII 符号)
Program read to cell #1, #2 and result will be appear in cell #3
I use BF interpreter where I can input numbers as numbers(not ASCII Symbols)
好吧,我可能没有最有效的方法,但它确实有效。我以特定的方式做事,以便它适用于所有这些
所以,这里是:
我使用了这个解释器: http://esoteric.sange.fi/brainfuck/impl/interp/i.html
Well, I might not have the most efficient way around it, but it works. I did things in a specific ways so that it would work with all of these
So, here it is:
I used this interpreter: http://esoteric.sange.fi/brainfuck/impl/interp/i.html
好吧,我受到第一个的启发,使它变得更加简单:
最后的 48+ 是为了让 bfdev 以 ascii 形式显示它。
well, I was inspired by the first one and made it much more simple:
the 48+ in the end is for the bfdev to show it in ascii.
该帖子是 12 年前发布的,但我仍然想分享我的答案,以防其他人看到这个帖子。
Post was made 12 years ago but I’d still like to share my answer just incase someone else see this thread.
我知道这是八年前发布的,但我仍然想分享我的答案,以防其他人偶然发现这个帖子。
这使用了八个单元格的空间,这些单元格都应该初始化为零(如果您在较大的程序中使用它),并且指针从八个单元格的最左边开始。它将接收两个个位 ASCII 数字并输出一个两位位 ASCII 数字。我所说的 ASCII 数字是指它将接收并输出组成该数字的字符的 ASCII 值。当该程序完成时,指针将再次位于八个单元格的最左端,并且所有单元格将返回到零。在正常操作中,这将在磁带上产生的值不会低于 0 或超过 81,因此您无需担心底片或回绕。
I know this was posted over eight years ago, but I’d still like to share my answer in case anyone else stumbles across this thread.
This uses eight cells of space which should all be initialized with zero (in case your using this in a larger program) and the pointer begins at the left most of the eight cells. It will take in two single digit ASCII numbers and output a single two digit ASCII number. By an ASCII number, I mean it will take in and output the ASCII values of the characters making up the number. When this program is done, the pointer will once again be at the left most end of the eight cells and all cells will have been returned to zero. The values this will produce on the tape in normal operation will not go below 0 or exceed 81, so you don’t need to worry about negatives or wrapping.
有点难以理解,但确实有效
Kinda hard to understand, but it works
我知道这个问题已经有 11 年历史了,但这是给未来读者的。
I know this question is 11 years old but this is for future readers.
我发现这个非常非常简单的版本在第二个单元格中输出答案
++[>++<-]
此示例将 2 乘以 2,开头和括号循环中的 + 数量是要相乘的数字
I found this VERY VERY simple version that outputs the answer in the second cell
++[>++<-]
This example multiplies 2 by 2 and the number of +s in the beginning and in the bracket loop are the numbers to be multiplied