I am creating a sudoku game in C++ and i need to diplay the game board. How can i display an Array with charcters sectioned off?
<p>I was tasked to create a Sudoku game in my programming class using arrays.  </p>

<p>I made a <em>very messy</em> attempt at trying to display the 9x9 Array with the "-" in-between the 3x3 squares. </p>

<p>The code compiles but the display of the board is off, the "-" is in places it shouldn't and isn't there sometimes when it should be. </p>

<p>I'm fairly new to C++ and thanks for the help! Here is what I have for the display functions:</p>

<pre><code>for (int x = 0; x &lt; 11; x++)
{
for (int y = 0; y &lt; 11; y++)
{
    if(board[x][y] == 0)
    {
        cout &lt;&lt; setw(2) &lt;&lt; "   ";
    }
    else
    {
     if (x &gt; 3 &amp;&amp; x &lt; 7 &amp;&amp; y &gt; 3 &amp;&amp; y &lt; 7 &amp;&amp; board[x-1][y-1] != 0)
    {
        cout &lt;&lt; setw(2) &lt;&lt; board[(x-1)][(y-1)] &lt;&lt; " ";
    }
    else if (x &gt; 3 &amp;&amp; x &lt; 7 &amp;&amp; y &lt; 3  &amp;&amp; board[x-1][y] != 0)
    {
        cout &lt;&lt; setw(2) &lt;&lt; board[(x-1)][(y)] &lt;&lt; " ";
    }
    else if (x &gt; 7 &amp;&amp; y &lt; 3 &amp;&amp; board[x-2][y] != 0)
    {
        cout &lt;&lt; setw(2) &lt;&lt; board[(x-2)][(y)] &lt;&lt; " ";
    }
    else if (x &lt; 3 &amp;&amp; y &gt; 3 &amp;&amp; y &lt; 7 &amp;&amp; board[x][y-1] != 0)
    {
        cout &lt;&lt; setw(2) &lt;&lt; board[(x)][(y-1)] &lt;&lt; " ";
    }
    else if (x &lt; 3 &amp;&amp; y &gt; 7 &amp;&amp; board[x][y-2] != 0)
    {
        cout &lt;&lt; setw(2) &lt;&lt; board[(x)][(y-2)] &lt;&lt; " ";
    }
        else if (x &gt; 3 &amp;&amp; x &lt; 7 &amp;&amp; y &gt; 7 &amp;&amp; board[x-1][y-2] != 0)
    {
        cout &lt;&lt; setw(2) &lt;&lt; board[(x-1)][(y-2)] &lt;&lt; " ";
    }
    else if (x &gt; 7 &amp;&amp; y &gt; 7 &amp;&amp; board[x-2][y-2] != 0)
    {
        cout &lt;&lt; setw(2) &lt;&lt; board[(x-2)][(y-2)] &lt;&lt; " ";
    }
    else if (x &gt; 7 &amp;&amp; y &gt; 3 &amp;&amp; y &lt; 7 &amp;&amp; board[x-2][y-1] != 0)
    {
        cout &lt;&lt; setw(2) &lt;&lt; board[(x-2)][(y-1)] &lt;&lt; " ";
    }

    else if (x &lt; 3 &amp;&amp; y &lt; 3)
    {
        cout &lt;&lt; setw(2) &lt;&lt; board[x][y] &lt;&lt; " ";
    }
    else 
    {
        cout &lt;&lt; setw(2) &lt;&lt; "-" &lt;&lt; " ";
    }
    }
}
cout &lt;&lt; endl;
}
</code></pre>