Sha256: 71ab7874a4631a3b5d0292f7200d384c3913a85002aa52b19d4a518246946877

Contents?: true

Size: 1.26 KB

Versions: 13

Compression:

Stored size: 1.26 KB

Contents

#include <stdio.h>
#define GRID_SIZE 100 
#define MAX_ITER 1000


int grid[GRID_SIZE][GRID_SIZE] = {0};

void printGrid(void) {
    int i, j;
    for(i = 0; i<GRID_SIZE; i++) {
        for(j = 0; j<GRID_SIZE; j++) {
            int iter = grid[i][j];
            if(iter == -1) {
                putchar(' ');
            }
            else if(iter < 20) {
                putchar('/');
            }
            else if(iter < 50) {
                putchar('^');
            }
            else if(iter < 100) {
                putchar('/');
            }
            else {
                putchar('(');
            }
        }
        putchar('\n');
    }

}

int main (void) {
    int i, j, iter;

    for(i = 0; i<GRID_SIZE; i++) {
        for(j = 0; j<GRID_SIZE; j++) {  
            double x_0 = i/(GRID_SIZE/3.5)-2.5;
            double y_0 = j/(GRID_SIZE/2.0)-1.0;
            double x = 0, y = 0;
            
            for (iter = 0; x*x + y*y < 4 && iter < MAX_ITER; iter++) {
                double xtemp = x*x - y*y + x_0;
                y = 2*x*y + y_0;
                x = xtemp;
            }

            if(x*x + y*y < 4)
                grid[i][j] = -1;
            else {
                grid[i][j] = iter;
            }
        }
    }

    printGrid();
    return 0;
}

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
zsh_dots-0.6.5 etc/mandlebrot.c
zsh_dots-0.6.3 etc/mandlebrot.c
zsh_dots-0.6.2 etc/mandlebrot.c
zsh_dots-0.6.0 etc/mandlebrot.c
zsh_dots-0.5.9 etc/mandlebrot.c
zsh_dots-0.5.8 etc/mandlebrot.c
zsh_dots-0.5.7 etc/mandlebrot.c
zsh_dots-0.5.6 etc/mandlebrot.c
zsh_dots-0.5.5 etc/mandlebrot.c
zsh_dots-0.5.4 etc/mandlebrot.c
zsh_dots-0.5.3 etc/mandlebrot.c
zsh_dots-0.5.1 etc/mandlebrot.c
zsh_dots-0.5.0 etc/mandlebrot.c