summaryrefslogtreecommitdiff
path: root/ll/ding.c
blob: b6b4bf243c26954bff21cf80722d4f9b970386d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <stdio.h>

int mandeliter(double x,double y){
	double a=x,b=y;
	int n=0;
	while(n<256){
		double na=a*a-b*b+x;
		double nb=2*a*b+y;
		a=na;
		b=nb;
		if(a*a+b*b>4)break;
		n++;
	}
	return n;
}

int main(void){
	double x,y;
	y=1.5;
	while(y>=-1.5){
		x=-2;
		while(x<=1){
			int n=mandeliter(x,y);
			printf("%3d ",n);
			x+=0.0625;
		}
		y-=0.125;
		putchar('\n');
	}
}