今日已更新 63 条资讯 | 累计 20533 条内容
关于我们

Insert, a language for self-modifying code

/u/uellenberg 2026年06月27日 06:36 1 次阅读 来源:Reddit r/programming

If you ever find yourself with time to kill and crave a fun challenge, you can write a program that prints out its own source code, called a quine ). Go on, give it a try, it's good fun! Once that's done, what's to stop you from modifying the source code instead of printing it verbatim, slowly shifting forms as you iterate on each successive output? Naturally, you'll want to make a game that's played in its own source code (click for an animation): #include<stdio.h> #define z else #define y return #define x int #define w if( #define v putchar( #define B v 10); #define A v 92); /* IOCCC29, w = up, e = down */ x a= 32 ; x b= 6 ; x c= -1 ; x d= 1 ; x e= 5 ; x f= 10 ; x g= 62 ; x h= 5 ; x i[6]={ 1,3,1,4,1,0} ; char*j[]={ "\ \ #include<stdio.h>'#define$z$else'#define$y$return'#define$x$int'#defin\ e$w$if('#define$v$putchar('#define$B$v$10);'#define$A$v$92);''/*$IOCCC\ 29,$w$=$up,$e$=$down$*/''x$a=","32",";x$b=","6",";x$c=","-1",";x$d=","\ 1",";x$e=","5",";x$f=","10",";x$g=","62",";x$h=","5",";x$i[6]={1,3,1,4\ ,1,0};char*j[]={","","};x$k=0;x$l=1;x$m(){l++;w$l==1)y!v$44);w$l==2)y!\ v$34) ;char$o=j[k][l-3];w!o){l=0;k++;y!v$34);}w$o==34){A$y$v $34);\ }w$o= =92){A$y$A}w$o!=32&&o!=1 0)y!v$o);y$m();}void$n(x$o, x$p){\ aspri ntf(j+o,\"%i\",p);}x$mai n(x$o,char**p){char*q;w$c<2 )a+=c\ ;b+=d ;x$r=b+2>f/2&&b<f/2+5;x$s=a+2==g&&b+2>h&&b<h+5;w$c<2){ w$a==\ e+2&& r||s){a-=c;b-=d;c=-c;}w$a<0||a>67){w$a<0){c=2;d=0;}a=3 4;b=6\ ;}w$b<0||b>13){b-=d;d=-d;}w$f/2>10)f-=2;w$h>10)h--;w$o>1){w*p[1]==119&\ &h>0)h--;w*p[1]==101&&h<10)h++;}s=f/2-b+1;w$s<0)f++;w$s>0)f--;}z{b++;w\ $d<0)d++;w$b>=13){w$o>1&&*p[1]==119)d=-4;b=13;}w$f/2<15-i[c-2])f+=2;z$\ e--;w$h<15-i[c-1])h++;z$g--;w$e+3<=0){c++;w$c<7){e=g;f=h*2;g=70;h=15-i\ [c-1];}z{e=5;g=62;c=1;d=1;}}w$a+2==e&&r||s){c=2;e=5;f=28;g=62;h=12;}}n\ \ (1,a);n(3,b);n(5,c);n(7,d);n(9,e);n(11,f);n(13,g);n(15,h);for(s=0;s<","29",";s++){w$s)v$32);q=j[s];r=1;for(char*t=q;*t;t++)w*t==","36",")v$32);z$w*t==","39",")B$z$w*t!=32&&*t!=10){r=0;v*t);w*t==123||*t==125||*t

本文内容来源于互联网,版权归原作者所有
查看原文