我写了一个 C 程序,它自己打印 n 次,但我不知道如何反向打印同样的 n 次。例如,如果示例程序是:
hello
那么要求的输出应该是 "olleh"for n=1
。
这是我的 quine 程序,
#include <stdio.h>
int main()
{
int n;
char c;
FILE *f;
f=fopen(__FILE__,"r");
scanf("%d",&n);
while(n--)
{
while((c=getc(f))!=EOF)
putchar(c);
fseek(f,0,0);
}
return 0;
}
最佳答案
这不是纯奎因。参见 the Quine article in Wikipedia :
A quine takes no input. Allowing input would permit the source code to be fed to the program via the keyboard, opening the source file of the program, and similar mechanisms.
关于c - 如何反转蒯因?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3693924/