Asking for help to troubleshoot a c++ Eight queens puzzle code
<p>I have written a function in C++ code for the <a href="http://en.wikipedia.org/wiki/Eight_queens_puzzle" rel="nofollow">eight queens problem</a>.  The program is supposed to print out all 92 possible solutions.  I only can run up to 40.  Don't know where the problem is.  Try to debug but I'm still stuck.</p>

<pre><code>#include "stdafx.h"
#include &lt;cmath&gt;
#include &lt;iostream&gt;
using namespace std;

bool ok(int board[8][8]){
    for(int c = 7; c &gt; 0; c--){
        int r = 0;
        while(board[r][c] != 1 ){
            r++;
        } // while loop

        for(int i = 1; i &lt;= c; i++){
            if(board[r][c-i] == 1)
                return false;
            else if (board[r-i][c-i] == 1)
                return false;
            else if (board[r+i][c-i] == 1)
                return false;
        } // for loop

    } // for loop
        return true;
} // ok

void print(int board[8][8], int count){
    cout &lt;&lt; count &lt;&lt; endl;
    for(int i = 0; i &lt; 8; i++){
        for(int j = 0; j &lt; 8; j++){
            cout &lt;&lt; board[i][j];
        } // for loop 
        cout &lt;&lt; endl;

    } // for loop

    cout &lt;&lt; endl;
} // print board

int main (){

    int board[8][8]={0};
    int count = 0;
    for(int i0 = 0; i0 &lt; 8; i0++)
       for(int i1=0; i1 &lt; 8; i1++)
          for(int i2 = 0; i2 &lt; 8; i2++)
         for(int i3 = 0; i3 &lt; 8; i3++)
            for(int i4 = 0; i4 &lt; 8; i4++)
           for(int i5 = 0; i5 &lt; 8; i5++)
              for(int i6 = 0; i6 &lt; 8; i6++)
                 for(int i7 = 0; i7 &lt; 8; i7++){
                board[i0][0]=1;
                            board[i1][1]=1;
                            board[i2][2]=1;
                            board[i3][3]=1;
                            board[i4][4]=1;
                            board[i5][5]=1;
                            board[i6][6]=1;
                            board[i7][7]=1;

                            if(ok(board))print(board, ++count);

                            board[i0][0]=0;
                            board[i1][1]=0;
                            board[i2][2]=0;
                            board[i3][3]=0;         
                            board[i4][4]=0; 
                            board[i5][5]=0;
                            board[i6][6]=0;
                            board[i7][7]=0;

                                }
    return 0;
}
</code></pre>
