用c++实现,输出在控制台
#include<iostream>
using namespace std;
int main() {
double realCoord, imagCoord, realTemp, imagTemp, realTemp2, arg;
int interation;
char outPut[4]{ '.','o','O','@' };
for (imagCoord = 1.2; imagCoord >= -1.2; imagCoord -= 0.05)
{
for (realCoord = -0.6; realCoord <= 1.77; realCoord += 0.03)
{
interation = 0;
realTemp = realCoord;
imagTemp = imagCoord;
arg = realCoord * realCoord + imagCoord * imagCoord;
while (arg < 4 && interation < 40)
{
realTemp2 = realTemp * realTemp - imagTemp * imagTemp - realCoord;
imagTemp = 2 * realTemp * imagTemp - imagCoord;
realTemp = realTemp2;
arg = realTemp * realTemp + imagTemp * imagTemp;
interation++;
}
std::cout << outPut[interation % 4];
}
cout << endl;
}
system("pause");
return 0;
}
转载:https://blog.csdn.net/sandalphon4869/article/details/101037247
查看评论