Tag: quine

打印自己的程序,它是如何工作的?

我遇到了一个在这个网站上打印自己的程序,即打印程序代码。 程序代码是: #include char *program = “#include %cchar *program = %c%s%c;%cint main()%c{%cprintf(program, 10, 34, program, 34, 10, 10, 10, 10, 10, 10);%c return 0;%c}%c”; //what is this line doing, what is the use of %c and %s and what properties of %c and %s are being used here? int main() { printf(program, 10, 34, program, […]

C / C ++程序打印自己的源代码作为输出

维基百科称它被称为quine,有人给出了以下代码: char*s=”char*s=%c%s%c;main(){printf(s,34,s,34);}”;main(){printf(s,34,s,34);} 但是,显然你必须添加 #include //corrected from #include 这样printf()可以工作。 从字面上看,由于上面的程序没有打印#include ,它不是解决方案(?) 我对“打印自己的源代码”的字面要求以及此类问题的任何目的感到困惑,尤其是在访谈时。