C#案例陈述未输入
我目前正在努力完成一本Wrox C#书。但是,在显示Mandelbrot集的其中一个教程之后,我能够无误地执行程序,但是控制台中没有显示任何内容。我把这归因于我使用的开关使用不当。谁能给我指一下正确的方向吗C#案例陈述未输入,c#,for-loop,switch-statement,mandelbrot,C#,For Loop,Switch Statement,Mandelbrot,我目前正在努力完成一本Wrox C#书。但是,在显示Mandelbrot集的其中一个教程之后,我能够无误地执行程序,但是控制台中没有显示任何内容。我把这归因于我使用的开关使用不当。谁能给我指一下正确的方向吗 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Ch03Ex06 { clas
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ch03Ex06
{
class Program
{
static void Main(string[] args)
{
double realCoord, imagCoord;
double realTemp, imagTemp, realTemp2, arg;
int iterations;
for (imagCoord = 1.2; imagCoord >= -1.2; imagCoord -= 0.05)
{
for (realCoord = -0.6; realCoord <= 1.77; realCoord += 0.03)
{
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 * realTemp) - imagCoord;
arg = (realTemp * realTemp) + (imagTemp * imagTemp);
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");
}
Console.ReadKey();
}
}
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用System.Threading.Tasks;
名称空间Ch03Ex06
{
班级计划
{
静态void Main(字符串[]参数)
{
双realCoord、imagCoord;
双realTemp、imagTemp、realTemp2、arg;
整数迭代;
对于(imagCoord=1.2;imagCoord>=-1.2;imagCoord-=0.05)
{
对于(realCoord=-0.6;realCoord我想程序会永远运行,因为这行代码
while ((arg < 4) && (iterations < 40));
while((arg<4)和&(迭代次数<40));
末尾的;关闭此while循环而不进入下一个块您有一个输入错误:
while((arg<4)和&(迭代次数<40));
;必须删除这是您的问题,请删除分号
while ((arg < 4) && (iterations < 40));
while((arg<4)和&(迭代次数<40));
你试过调试它吗?我知道我错过了树上的树林……或者其他什么说法。非常感谢。