ASCII Art: Mandelbrot Fractal
At the top of Ken Perlin’s homepage there is a strange C code:
COMPILE THIS:
main(k){float i,j,r,x,y=-16;while(puts(""),y++<15)for(x
=0;x++<84;putchar(" .:-;!/>)|&IH%*#"[k&15]))for(i=k=r=0;
j=r*r-i*i-2+x/25,i=2*r*i+y/10,j*j+i*i<11&&k++<111;r=j);}
I couldn't resist to test it. I just modified it a little bit to make it more readable:
int main(int argc, char** argv)
{
int k = 2;
float i,j,r,x,y=-16;
while (puts(""), y++<15)
for (x=0; x++<84; putchar(" .:-;!/>)|&IH%*#"[k&15]))
for (i=k=r=0;
j=r*r-i*i-2+x/25,i=2*r*i+y/10,j*j+i*i<11&&k++<111;
r=j);
return 0;
}
The result of the execution of this code ? Simply the Mandrelbrot set in ASCII
Tweet
[ Subscribe to Geeks3D latest news by email ]















Thanks for posting. That’s why I love C… but we all understand that this is the dark side of the force
cool
I love C too — better than fairy land c++
i belong to and love the dark side