#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define MAX 150
#define ZOOM 800.0
int main()
{
FILE *fp;fp=fopen("c:\\mandelbrot.txt","w");
int i,x,y;
double re;//x
double im;//y
double tx,ty; // (x + iy)
const double x0=0.5,y0=-0.000397;
fprintf(fp,"%.6f + %.6fi\n",x0,y0);
for(y=MAX;y>=-MAX;y--)
for(x=-MAX;x<=MAX;x++)
{
re=x/ZOOM+0.6;
im=y/ZOOM+0.5;
for(i=0;i<15;i++)
{
tx=re;ty=im;
re=tx*tx-ty*ty; //x²-y²
im=2.0*tx*ty; // 2xy
re+=x0;
im+=y0;
}
if(re>0.01)
fprintf(fp," ");
else
fprintf(fp,"O");
if(x==MAX)
fprintf(fp,"\n");
}
}
#include <stdlib.h>
#include <math.h>
#define MAX 150
#define ZOOM 800.0
int main()
{
FILE *fp;fp=fopen("c:\\mandelbrot.txt","w");
int i,x,y;
double re;//x
double im;//y
double tx,ty; // (x + iy)
const double x0=0.5,y0=-0.000397;
fprintf(fp,"%.6f + %.6fi\n",x0,y0);
for(y=MAX;y>=-MAX;y--)
for(x=-MAX;x<=MAX;x++)
{
re=x/ZOOM+0.6;
im=y/ZOOM+0.5;
for(i=0;i<15;i++)
{
tx=re;ty=im;
re=tx*tx-ty*ty; //x²-y²
im=2.0*tx*ty; // 2xy
re+=x0;
im+=y0;
}
if(re>0.01)
fprintf(fp," ");
else
fprintf(fp,"O");
if(x==MAX)
fprintf(fp,"\n");
}
}