1[d=b] 是什么意思? [英] What does 1[d=b] mean?

查看:94
本文介绍了1[d=b] 是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究 160 字节的 BrainFuck 代码,试图弄清楚它做了什么,但我似乎无法弄清楚 1[d=b] 做了什么.

I was working through the 160 byte BrainFuck code trying to figure out what things do, and I cant seem to figure out what 1[d=b] does.

s[99],*r=s,*d,c;main(a,b){char*v=1[d=b];for(;c=*v++%93;)for(b=c&2,b=c%7?a&&(c&17
?c&1?(*r+=b-1):(r+=b-1):syscall(4-!b,b,r,1),0):v;b&&c|a**r;v=d)main(!c,&a);d=v;}

这是代码,大约在第一行的中间
http://j.mearie.org/post/1181041789/brainfuck-interpreter-in-2-lines-of-c

Heres the code, its about midway through the first line
http://j.mearie.org/post/1181041789/brainfuck-interpreter-in-2-lines-of-c

我不是在问它在那种情况下做什么,而是首先问 1[] 做什么.

I'm not asking what it does in that context but what 1[] does in the first place.

谢谢 =)

推荐答案

在 C 中,x[7]7[x] 之间没有区别.它们都等于 *(x+7)(和 *(7+x) 因为加法是可交换的),这意味着 x数组.

In C, there is no difference between x[7] and 7[x]. They both equate to *(x+7) (and *(7+x) since addition is commutative) which means the seventh element of the x array.

在这种特殊情况下 (1[d=b]),首先将 b 的当前值赋给 d,然后计算1[d]d[1] 相同.

In this particular case (1[d=b]), you first assign the current value of b to d, then calculate 1[d] which is the same as d[1].

通过这样做(offset[base] 而不是 base[offset]),它允许你将它与赋值结合起来,否则你需要:

By doing it this way (offset[base] rather than base[offset]), it allows you to combine it with the assignment, otherwise you'd need:

d = b; char *v = d[1];

<小时>

我想我不需要告诉您这实际上是非常糟糕的代码,正如您必须非常认真地思考它的含义这一事实所证明的那样.更好的代码几乎可以立即破译.


I suppose I shouldn't need to tell you that this is actually very bad code, as evidenced by the fact that you have to think very hard about what it means. Better code would be almost instantly decipherable.

这篇关于1[d=b] 是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆