Skip to content

Instantly share code, notes, and snippets.

@lelandbatey
Last active August 29, 2015 14:06
Show Gist options
  • Save lelandbatey/99f3c4b99c621c12631d to your computer and use it in GitHub Desktop.
Save lelandbatey/99f3c4b99c621c12631d to your computer and use it in GitHub Desktop.
Tiny binary tree printer.
typedef int j;j p(j t,j l){for(;l;--l)putchar(t);}
j main(j c,j**v){j i,h=5;c>1?h=atoi(v[1]):0;h=1<<h;j b=h;for(;b;){b/=2;
for(i=b?h/b:0;i;i--)p(32,b-1),p(!(i%2)*32+32,1);p(10,1);}}
//Prints the following:
//
// @
// @ @
// @ @ @ @
// @ @ @ @ @ @ @ @
//@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @
//
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment