title: C++-Is it obvious?
body: <p>I am supposed to be converting a permutation program into an 8 of queens program. The program is supposed to put a queen down in the first row, then in the second row it is supposed to place down a queen that is not in direct view of the prior queen. At the end, if 8 queens cannot be placed, the program shall pick up the previous queen and recalculate.</p>
  
  <p>The output for this program is as follows.</p>
  
  <p>Executing the program....</p>
  
  <pre><code>$demo 
  Q _ _ _ _ _ _ _ 
  _ _ _ _ _ _ _ Q 
  _ _ _ _ _ _ Q _ 
  _ _ _ _ _ _ _ Q 
  _ _ _ _ _ _ Q _ 
  _ _ _ _ _ _ _ Q 
  _ _ _ _ _ _ Q _ 
  _ _ _ _ _ _ _ Q 
  </code></pre>
  
  <p>(It's 8x8)</p>
  
  <p>Clearly those last two rows are in direct sight of eachother, and i'm unsure of where i should start by fixing this, if I could get input that would be great, hopefully it isn't something obvious!</p>
  
  <p>Code:</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;iomanip&gt;
  #include&lt;limits&gt;
  using namespace std;
  
  char BOARD[8][8];
  
  void clearBoard();
  void attempt(int n, int row, int column);
  void placeQueen(int row, int column);
  void removeQueen(int row, int column);
  bool currentPathSuccess(int n, int row, int column);
  bool currentPathStillViable(int row, int column);
  void printBoard(int n);
  
  
  int main()
  {
      int n = 8;
      clearBoard();
      for(int i = 0; i &lt; n; i++)
      {
          for(int j = 0; j &lt; n; j++)
          {
              attempt(n, i, j);
          }
      }
      printBoard(n);
      return 0;
  }//end Main
  
  void clearBoard()
  {
      for(int i = 0; i &lt; 8; i++)
      {
          for(int j = 0; j &lt; 8; j++)
          {
              BOARD[i][j] = '_';
          }
      }   
  }//end clearBoard Function
  
  void attempt(int n, int row, int column)
  {
      placeQueen(row, column);
  
      if(currentPathSuccess(n, row, column))
          {printBoard(n);}
          else
      currentPathStillViable(row, column);
  }// end attempt Function
  
  void placeQueen(int row, int column)
  {
      BOARD[row][column] = 'Q';
  }
  void removeQueen(int row, int column)
  {
      BOARD[row][column] = '_';
  }//end placeQueen Function
  
  bool currentPathSuccess(int n, int row, int column)    //Flag
  {
      bool success = true;
  
      if((n &gt; column)||(n &gt; row))
         { 
             success = false;
         }
      return success;
  }//end currentPathSuccess Function
  
  bool currentPathStillViable(int row, int column)    //Flag
   {
      bool viable = true;
      int flag = 0;
  
      for(int x = 0; x &lt; 8; x++)
      {
          if(BOARD[row][x] == 'Q')
          {
               flag++;
          }
      }
      if(flag &gt; 1)
      {
          removeQueen(row, column);
          placeQueen(row + 1, column);
      }
      return viable;
  }// end currentPathStillViable
  
  void printBoard(int n)
  {
      for(int i = 0; i &lt; n; i++)
      {
          for(int j = 0; j &lt; n; j++)
          {
              cout &lt;&lt; BOARD[i][j] &lt;&lt; " ";
          }
          cout &lt;&lt; endl;
      }
      cout &lt;&lt; endl;
  }//end printBoard Function
  </code></pre>