可打印自身代码的代码
代码如下:程序代码:
#include <stdio.h>
void main()
{
char *s="#include <stdio.h>%cvoid main()%c{%c%cchar *s=%c%s%c;%c%cprintf(s,10,10,10,9,34,s,34,10,9,10);%c}";
printf(s,10,10,10,9,34,s,34,10,9,10);
}
void main()
{
char *s="#include <stdio.h>%cvoid main()%c{%c%cchar *s=%c%s%c;%c%cprintf(s,10,10,10,9,34,s,34,10,9,10);%c}";
printf(s,10,10,10,9,34,s,34,10,9,10);
}
/*
* 注: 10是字符'\n', 34 是字符'"', 9是字符'\t'
*/
[[it] 本帖最后由 hoodlum1980 于 2008-3-19 00:06 编辑 [/it]]
----------------解决方案--------------------------------------------------------
真的呀 !挺神奇的
----------------解决方案--------------------------------------------------------
批评一点:void main 错
更正后运行,评价:想出来的人很强大
只可惜不是所有代码都可以
[[it] 本帖最后由 雨中飞燕 于 2008-3-19 00:19 编辑 [/it]]
----------------解决方案--------------------------------------------------------
#include <stdio.h>
void main()
{
char *s="#include <stdio.h>%cvoid main()%c{%cchar *s=%c%s%c;%c%cprintf(s,10,10,9,34,s,34,10,9,10);%c}";
printf("#include <stdio.h>%c",10);
printf("void main()%c",10);
printf("{");
printf("%cchar *s=%c",9,34);
printf("%s%c;%c%cprintf(s,10,10,9,34,s,34,10,9,10);%c",s,34,10,9,10);
printf("}");
}
----------------解决方案--------------------------------------------------------
#include <stdio.h>
void main()
{
char *s="#include <stdio.h>%cvoid main()%c{%cchar *s=%c%s%c;%c%cprintf(s,10,10,9,34,s,34,10,9,10);%c}";
printf("#include <stdio.h>%c",10);
printf("void main()%c",10);
printf("{");
printf("%cchar *s=%c",9,34);
printf("%s%c;%c%cprintf(s,10,10,9,34,s,34,10,9,10);%c",s,34,10,9,10);
printf("}");
}
----------------解决方案--------------------------------------------------------
这网真是够呛...
----------------解决方案--------------------------------------------------------
我也来气一气飞燕姐姐~
程序代码:
main(a){a="main(a){a=%c%s%c;printf(a,34,a,34);}";printf(a,34,a,34);}
----------------解决方案--------------------------------------------------------
都用同一个方法就没意思了
----------------解决方案--------------------------------------------------------
能否解释下里面的每一步骤
char *s="#include <stdio.h>%cvoid main()%c{%c%cchar *s=%c%s%c;%c%cprintf(s,10,10,10,9,34,s,34,10,9,10);%c}";printf(s,10,10,10,9,34,s,34,10,9,10);
----------------解决方案--------------------------------------------------------
没什么意思...就是一个打印..把%c换上后面的指定的值..都是些回车换行的值
----------------解决方案--------------------------------------------------------