我标记的 else 有一个错误,说它是不必要的。我怎样才能让 else 与第一个 if 一致?
if (heading < 270 && heading > 90)
directionToFace= 'S';
if (heading > 180)
{
degreeToWalk = (heading-180);
directionToWalk = 'W';
}
else
{
degreeToWalk = (180-heading);
directionToWalk = 'E';
}
else//this is where the error occurs
directionToFace='N';
{
if (heading > 270)
{
degreeToWalk =(heading-270);
directionToWalk='W';
}
else
{
degreeToWalk = (heading);
directionToWalk = 'E';
}
}