Gray code by pascal

i,m;main(N){for(printf("Gray code  n=%d",N=getchar()-48);i<1<<N;i++)for(m=N;putchar(m-N?48|(i^i/2)>>m&1:10),m--;);}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page