Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Post your Sierpinksi

Name: Anonymous 2011-01-17 17:40

Write a program to print k-th iteration (where k is given as an argument) of the Sierpinski triangle on standard output in your language of choice, then post it in this thread. Convoluted solutions more than welcome.

Name: Anonymous 2011-01-17 23:13

Easy version:

#include <stdio.h>

int main(int argc, char *argv[])
{
    int x, y, n;

    n = (argv[1] ? 1 << atoi(argv[1]) : 64);

    for (x = 0; x < n; x++) {
        for (y = 0; y < n; y++) {
            putchar(x & y ? ' ' : '#');
        }
        putchar('\n');
    }

    return 0;
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List