// Mandelbrot.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
double realCoord,imagCoord;
double realMax = 1.77;
double realMin = -0.6;
double imagMax = -1.2;
double imagMin = 1.2;
double realStep;
double imagStep;
double realTemp,imagTemp,realTemp2,arg;
int iterations;
while(true)
{
realStep = (realMax - realMin)/79;
imagStep = (imagMax - imagMin)/48;
for(imagCoord = imagMin; imagCoord >= imagMax;imagCoord+=imagStep)\
{
for(realCoord = realMin;realCoord<=realMax;realCoord +=realStep)
{
iterations = 0;
realTemp = realCoord;
imagTemp = imagCoord;
arg = (realCoord * realCoord) + (imagCoord * imagCoord);
while((arg < 4) && (iterations < 40))
{
realTemp2 = (realTemp * realTemp) - (imagTemp * imagTemp) - realCoord;
imagTemp = (2 * realTemp * imagTemp) - imagCoord;
realTemp = realTemp2;
arg = (realTemp * realTemp)+(imagTemp * imagTemp);
iterations +=1;
}
switch(iterations % 4)
{
case 0:
cout<<".";
break;
case 1:
cout<<"o";
break;
case 2:
cout<<"O";
break;
case 3:
cout<<"@";
break;
}
}
cout<<"\n";
}
cout<<"Current limits:";
cout<<"realCoord: from "<<realMin<<" to "<<realMax<<endl;
cout<<"imagCoord: from "<<imagMin<<" to "<<imagMax<<endl;
cout<<"Enter new limits:"<<endl;
cout<<"realCoord: from:"<<endl;
cin>>realMin;
cout<<"realCoord: to:"<<endl;
cin>>realMax;
cout<<"imagCoord: from:"<<endl;
cin>>imagMin;
cout<<"imagCoord: to:"<<endl;
cin>>imagMax;
}
getch();
return 0;
}
|