title: Creation 2D array for Mine game
body: <p><br>Hello
  <br>I am trying to create emulation of "Mine game" </p>
  
  <p><br>suppose we have matrix
  <br>0   0   0   0 
  <br>0    0   -1    0 
  <br>0    0    0   -1  
  <br>0   -1    0   -1  </p>
  
  <p><br>now each cell that not equal -1 should be represent numbers of mines
  <br>here code 
     for(int i=0;i
  
  <pre><code>for(int j=0;j&lt;N;j++)
   if(box[i][j]!=-1)
    {
    switch (i)
   {
   case 0: 
   iLEFT=0;
   iRIGHT=1;break;
   case 3:
   iRIGHT=0;
   iLEFT=1;
   break;
   case 1:
   iLEFT=1;
   iRIGHT=1;
   break;
   case 2:
   iLEFT=1;
   iRIGHT=1;
   break;
   default:
    iLEFT=1;
   iRIGHT=1; 
     break;
  }
  
  
  
  switch (j)
    {
  case 0:
     jLEFT=0;`
     jRIGHT=1;
     break;
  case 3:
     jRIGHT=0;
     jLEFT=1;
     break;
     case 1:
     jLEFT=1;
     jRIGHT=1;
      break;
      case 2:
      jLEFT=1;
      jRIGHT=1;
      break;
      default:
      jLEFT=1;
      jRIGHT=1;
       break;
    } 
  
  // checking neighbor 
       if(box[i][j+jRIGHT]==-1)
           count+=1;
              if(box[i][j-jLEFT]==-1)
           count+=1;              
                      if(box[i+iRIGHT][j]==-1)
                   count+=1;
              if (box[i-iLEFT][j]==-1)
                count+=1; 
                  if(box[i-iLEFT][j-jLEFT]==-1)
                  {
                      if(i-iLEFT!=i) // trying to avoid double checking
                       count+=1;
                  }
                  if(box[i+iRIGHT][j-jLEFT]==-1)
                  {
                      if(i+iRIGHT!=i)  //trying to avoid double checking
                       count+=1;
                  }
                  if (box[i-iLEFT][j+jRIGHT]==-1)
                  {
                      if(i!=iLEFT) //trying to avoid double checking
                        count+=1;
                  }
  
                  if (box[i+iRIGHT][j+jRIGHT]==-1)
                  {
  
                      if(i!=iRIGHT) //trying to avoid double checking
                        count+=1;
                  }
  
                     box[i][j]=count;
                     count=0;
          }
  </code></pre>
  
  <p><br> My algorithm <br>
  <br> iLEFT present row step left.
  <br> iRIGHT present row step right.
  <br> jLEFT and JRIGHT same for column 
  <br> Suppose i=0 so we can step only one step right(down) 
   <br> if i=1 we can step up and done ..same for j <br></p>
  
  <p><br>  "Case statement " update iLEFT/iRIGTH and jLEFT/jRIGHT for for enable side steps
  <br> now "if" statement checking left/right up/done 2 diagonals for box[i][j](only one step always)
  <br>count counting performance of -1 values neighbor for box[i][j] </p>
  
  <p><br><strong>you can see I still have double checking for same cells</strong>
  <br>0   1   1   1 
   <br>  0   1   -1   2 
   <br>  1   2   4   -1 
   <br>  <strong><em>2</em></strong>   -1   <strong><em>4</em></strong>   -1 </p>