-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjsetnthpower.c
59 lines (40 loc) · 1.12 KB
/
jsetnthpower.c
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <stdio.h>
#include <graphics.h>
#include <complex.h>
#include <math.h>
int main()
{ int gd = DETECT,gm=0;
initgraph(&gd,&gm,NULL);
complex Z,C,t,q;
int n = 4, iter = 20, i;
C = -1 + I* 0;
float ec = pow(2,1.0/(n-1));
float zx, zy, qx, qy, tx, ty;
for (zx=-1 * ec ; zx <= ec; zx += 0.01)
{
for (zy = -1 * ec; zy <= ec; zy += 0.01)
{ tx = zx ;
ty = zy;
t = tx + I*ty;
for (i=0; i<iter ; i++)
{
q = t;
for(int i=1;i<n;i++)
{
q *= t;
}
qx = creal(q) + creal(C);
qy = cimag(q) + cimag(C);
tx= qx;
ty= qy;
t = tx + I * ty;
if((tx*tx + ty*ty) > ec*ec)
break;
}
if (i==iter)
putpixel(200 + 100 * zx, 200 + 100* zy, i);
}
}
getch();
closegraph();
}