奎因混乱。奎因实际上打印了什么?
quine 打印程序的实际代码(即未混淆的代码)还是打印混淆的程序?
Does a quine print the ACTUAL code of the program i.e not obfuscated or does it print the obfuscated program?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我不认为混淆与此有任何关系。通常 quine 会打印程序本身的实际源代码。
I don't think obfuscation has anything to do with it. Usually a quine prints the actual source code of the program itself.
假设您有一个 C 程序,它打印其源代码的“混淆”或其他修饰版本。例如,假设空格或变量名称存在差异。
那么该程序就不是 quine,因为根据定义,quine 是一个打印自身的程序,而“自身”是指完全相同的字节序列。但是该程序的输出一旦编译,将打印与原始程序相同的内容(因为它只是一个装饰变体),即它本身。所以输出是一个 quine。
这有时会简化编写 quine 的过程 - 只需编写一个“nearly-quine”,它可能无法获得完全正确的格式,运行一次,输出就是您实际的 quine。
这一切都假设 C 语言中有一个 quine。 x86 机器代码中的 quine 必须输出的不是其 C 源代码,而是构成 .exe 文件的相同字节序列。
我不确定你所说的“实际代码”而不是“混淆代码”是什么意思,但是为了测试某个东西是否是奎因,你必须决定它应该是哪种语言。也许通过决定你可以回答你自己的问题 - 你只是想要一个 C 中的 quine,还是一个与你的混淆器有关的 quine?
Suppose that you had a C program which prints an "obfuscated" or otherwise cosmetically modified version of its source. For example, suppose there's a difference in whitespace or variable names.
Then that program would not be a quine, since by definition a quine is a program which prints itself, and by "itself" we mean the exact same sequence of bytes. But the output of that program, once compiled, would print the same thing as the original program (since it's just a cosmetic variant), i.e. itself. So the output is a quine.
This sometimes eases the process of writing a quine - just write a "nearly-quine", which maybe doesn't get the formatting exactly right, run it once, and the output is your actual quine.
This is all assuming a quine in C. A quine in x86 machine code would have to output not its C source, but the same sequence of bytes that makes up the .exe file.
I'm not sure what you mean by "ACTUAL code" as opposed to "obfuscated code", but to test whether something is a quine or not, you have to decide what language it's supposed to be a quine in. Maybe by deciding that you can answer your own question - do you just want a quine in C, or a quine that has something to do with your obfuscator?
这是标准 C 中的实际 quine,可在 Wikipedia 找到:
您会注意到其结构相对简单。它使用包含程序文本的字符串常量作为格式字符串和要由
printf()
格式化的值之一。编译并运行时,它会准确地打印该行代码。
wiki 文章中提供了多种语言的 quines 示例,其中还包括一些 C 语言的示例。
Here is an actual quine in standard C, found at Wikipedia:
You will notice that its structure is relatively straightforward. It uses a string constant containing the text of the program as both the format string and one of the values to be formatted by
printf()
.When compiled and run, it prints exactly that single line of code.
There are examples of quines in a variety of languages, including several more in C, at the wiki article.
以下是一个简单的 quine 代码。该源代码需要保存为“quine_file.c”。编译并执行。
这里使用一个简单的文件指针,它用于逐行读取源文件并将其打印到标准输出。
Following is a simple quine code. This source code need to saved as "quine_file.c". Compile and execute.
Here a simple file pointer is taken and it is used to read the source file line by line and print it to the stdout.
quine 是一个打印自己列表的程序。这意味着当程序运行时,它必须精确地打印出程序员作为程序的一部分编写的那些指令(当然包括执行打印的指令以及打印中使用的数据)。
- David Madore
进一步阅读
示例
JavaScript 执行此程序将显示以下字符串
Featured in the art of code video@30米21秒
-迪伦·贝蒂
A quine is a program which prints its own listing. This means that when the program is run, it must print out precisely those instructions which the programmer wrote as part of the program (including, of course, the instructions that do the printing, and the data used in the printing).
- David Madore
Further reading
JavaScript example
when executed this program will display the following string
Featured in the art of code video @ 30m21s
- Dylan Beattie
将其保存在名为 printItself.c 的文件中 ... 前面示例的问题是,如果我在程序中添加一行,例如 int x;我还必须将其添加到字符串中,同时处理换行符和空格等...但在这个示例中,您可以添加任何您想要的内容。
Save it in a file named as printItself.c ... Problem with previous example is that if i add a line in program e.g int x; i will have to add it in the string also while taking care of newline and spaces etc ... but in this example you can add whatever you want.