以下代码 结果是实现一个类似葫芦的图形,可这段代码调试后却是每行只有一个。而已???
请高手帮忙,看一下问题出在哪里?
代码如下:
static void Main(string[] args)
{
double realCoord, imageCoord;
double realTemp, imageTemp, realTemp2, arg;
int iterations;
for (imageCoord = 1.2; imageCoord >= -1.2; imageCoord -= 0.05)
{
for (realCoord = -0.6; realCoord <= 1.77; imageCoord += 0.03)
{
iterations = 0;
realTemp = realCoord;
imageTemp = imageCoord;
arg = (realCoord * realCoord) + (imageCoord * imageCoord);
while ((arg < 4) && (iterations < 40))
{
realTemp2 = (realTemp * realTemp) - (imageTemp * imageTemp)
- realCoord;
imageTemp = (2 * realTemp * imageTemp) - imageCoord;
realTemp = realTemp2;
arg = (realTemp * realTemp) + (imageTemp * imageTemp);
iterations += 1;
}
switch (iterations % 4)
{
case 0:
Console.Write(".");
break;
case 1:
Console.Write("o");
break;
case 2:
Console.Write("O");
break;
case 3:
Console.Write("@");
break;
}
}
Console.Write("\n");
}
}
}
[此贴子已经被作者于2007-7-14 21:58:05编辑过]