title: C++ minesweeper AjacentMines
body: <p>Me and my brother am making a minesweeper game. We have made almost everything, but we have a problem with the find how many mines that are next to it. My brother tried to do it with if and else if statments, but I think it is better to use a loop. I made a loop, but I have a problem. It counts the left and right side. How should I fix it. Here is my code:</p>
  
  <pre><code>int p_col = col - 1;
  int p_row = row - 1;
  
  for (int j = 0; j &lt; 3; j++){
      if (p_col + j &gt;= 0){
          if (p_row + j &gt;= 0){
              if (row + j &lt;= height){
                  if (isTileMine(p_row + j, p_col))
                      miner++;
                  if (isTileMine(p_row + j, p_col + 1)){
                      //Teller ikke seg selv
                      if (p_row + j == p_row + 1){}
                      else{
                          miner++;
                      }
                  }
                  if (isTileMine(p_row + j, p_col + 2))
                      miner++;
              }
          }
      }
  }
  </code></pre>