继续声明的替代方法

问题描述

我正在寻找一种替换此函数中的continue语句的方法。内部规则指出无法使用它们,但是我很难实现不会导致其余代码无法正常运行的替换。

bool neighCheck (int i,int j,int a[][COLLENGTH])
{
   bool neighbourOnFire;
   int x,y,neighX,neighY,curreNeigh;

   /* Bool set up to change after neighbours looped*/
   neighbourOnFire = false;
   /* The neighbours -looping from -1 -> 1 to get index of each neighbour*/
   for (x = -1; x < 2; x++) {
      for (y = -1; y < 2; y++) {
         /* Disregards current (middle) cell*/
         if ((x == 0) && (y == 0)) {
            continue;
         }
         /* Get indexes of the neighbour we're looking at */
         neighX = i + x;
         neighY = j + y;
         /* Checks for edges*/
         if (neighX >= 0 && neighY >= 0 && neighX < ROWLENGTH
            && neighY < COLLENGTH) {
            /* Get the neighbour using the indexes above */
            curreNeigh = a[neighX][neighY];
            /* Test to see if the neighbour is burning */
            if (curreNeigh == fire) {
               neighbourOnFire = true;
               continue;
            }
         }
      }
   }
   return neighbourOnFire;
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)