如何输出code本身?code

2023-09-11 02:21:55 作者:心跳咖速- 我愛妳

多少种方法在那里让code输出本身?

How many ways are there to let the code output itself?

例如,下面写的code,

For example, write the code below,

public class Test
{
   public static void main(String[] args)
   {
      // some code
   }
}

要输出本身

public class Test
{
   public static void main(String[] args)
   {
      // some code
   }
}

(任何编程语言被接受)

(Any programming language is accepted)

编辑 这个问题已经回答了在历史的帖子, 搜索奎因或退房 http://stackoverflow.com/search?q=quine

EDIT This question has been answered in the historical posts, search "quine" or check out http://stackoverflow.com/search?q=quine

推荐答案

这就是所谓的编程奎因,并已对如此广泛讨论:

This is called a programming quine, and has been extensively discussed on SO:

http://stackoverflow.com/search?q=quine

另请参见

http://en.wikipedia.org/wiki/Quine_(computing)

http://www.nyx.net/~gthompso/quine.htm

http://www.madore.org/~david/computers/quine。 HTML