Здравствуйте! суть проблемы такова: пытаюсь нарисовать картинки с помощью Множество Мандельброта. Вот ссылка на ресурс-
http://fractalworld.xaoc.ru/Mandelbrot_set_and_Julia_set. Решил сам код переписать на С++, да вот не получается! Зацикливается. Помогите пожалуйста замечанием или советом!
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <conio.h>
#include <graphics.h>
const int iter=50;
const int max=16;
struct Obj
{
double x, y;
};
void GraphInit(){
int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "c:\\langs\\BC\\bgi");
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to exit the program:");
getch();
exit(1);
}
}
int main()
{
GraphInit();
Obj z, t, c;
int x, y, n;;
int mx, my;
mx=getmaxx()/2;
my=getmaxy()/2;
for(y=-my; y=my; y++)
{
for(x=-mx;x=mx;x++)
{
n=0;
c.x=x*0.005;
c.y=y*0.005;
z.x=1;
z.y=1;
while(pow(z.x,2)+pow(z.y,2)<max && n<iter)
{
t=z;
z.x=pow(t.x,2)-pow(t.y,2)+c.x;
z.y=2*t.x*t.y+c.y;
n++;
}
if(n<iter)
{
putpixel(mx+x, my+y,16-(fmod(n,16)));
}
}
}
getch();
closegraph();
return 0;
}