private void r(double[][] test)
{
if (test != null)
{
for (int i = 0; i < test.Length; i++)
{
for (int j = 0; j < test[i].Length; j++)
{
if (test[i][j] == 0)
{
next("向上", test, i, j, i, j);
}
}
} for (int i = 0; i < test.Length; i++)
{
for (int j = 0; j < test[i].Length; j++)
{
if (test[i][j].Equals(double.NaN))
{
test[i][j] = 0;
}
}
}
}
} private void next(string dire, double[][] test, int i, int j, int baseI, int baseJ)
{
if ((i != baseI || j != baseJ) && test[i][j] != 0)
{
test[i][j] = double.NaN;
} if ("向上".Equals(dire))
{
if (i - 1 < 0)
{
next("向右", test, baseI, baseJ, baseI, baseJ);
}
else
{
next("向上", test, i - 1, j, baseI, baseJ);
}
}
else if ("向右".Equals(dire))
{
if (j + 1 == test[0].Length)
{
next("向下", test, baseI, baseJ, baseI, baseJ);
}
else
{
next("向右", test, i, j + 1, baseI, baseJ);
}
}
else if ("向下".Equals(dire))
{
if (i + 1 == test.Length)
{
next("向左", test, baseI, baseJ, baseI, baseJ);
}
else
{
next("向下", test, i + 1, j, baseI, baseJ);
}
}
else if ("向左".Equals(dire))
{
if (j - 1 < 0)
{
return;
}
else
{
next("向左", test, i, j - 1, baseI, baseJ);
}
} }
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货