2007-03-02

shortest self-reproducing code

From http://www.nyx.net/~gthompso/quine.htm
总结的很全,各种语言都有,至少我听说的语言都提及了
摘录一些有趣的:

C的,很早就知道了,今天想起来帖出来

char*f="char*f=%c%s%c;main(){printf(f,34,f,34,10);}%c";main(){printf(f,34,f,34,10);}
可以把char*去了,只报warning

对这段代码,要么看不懂,要么会为其精妙的构思叫绝

很佩服作者



C++的,有点麻烦,但换汤不换药

Author: lapinski@utexas.edu

#include
main(){char*s="#include%cmain(){char*s=%c%s%c;cout.form(s,10,34,s,34,10);}%c";cout.form(s,10,34,s,34,10);}


Javascript的,有投机取巧的感觉

Author: Geoffrey A. Swift(blimey@toke.com)

function a() {
document.write(a, "a()");
}
a()





No comments: