Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<pre><code>#include &lt;stdio.h&gt; #include &lt;string.h&gt; #include &lt;stdlib.h&gt; #include &lt;time.h&gt; //FUNCTION: Draw the Board char tochar(int i) { return i+'0'; } void marker( int x, int y, char board[][19] ); int check(int x, int y, char board[][19]) { if(x&gt;1&amp;&amp;board[2*x+1][2*y+1]==board[2*x-1][2*y+1]) return 1; if(y&gt;1&amp;&amp;board[2*x+1][2*y+1]==board[2*x+1][2*y-1]) return 1; return 0; } int drawBoard() { //Declare array size char board[19][19]; memset(board,32, sizeof(board)); //initialize variables int rows, columns, randomNumber, flag; //random number seed generator srand(time(NULL)); for ( rows = 0 ; rows &lt; 9 ; rows++ ) { for ( columns = 0 ; columns &lt; 9 ; columns++ ) { flag = 0; do { //generate random numbers from 2 - 8 randomNumber = rand() %7 + 2; board[2*rows+1][2*columns+1] = tochar(randomNumber); //Display the 'box' if rows and columns == 5 / i.e - board[5][5] if ( rows == 4 &amp;&amp; columns == 4 ) { //Checks for 2 adjacent numbers if ( check(rows, columns, board)) { flag = 0; } else { flag = 1; marker( 2*rows+1, 2*columns+1, board ); //Print 'box' } } else { //Checks for 2 adjacent numbers. if ( check(rows, columns, board)) { flag = 0; } else //Prints the correct board { flag = 1; // printf( " %c ", board[2*rows+1][2*columns+1] ); } } } while ( flag == 0 ); //end outer do-while }//end inner for-loop printf("\n\n"); }//end outer for-loop for(rows=0;rows&lt;19;rows++) { for(columns=0;columns&lt;19;columns++) { printf("%c",board[rows][columns]); } printf("\n"); } }//end FUNCTION drawBoard //FUNCTION: Mark the surrounding of the number with "|" and "_" at board[5][5] void marker( int x, int y, char board[][19] ) { board[x][y-1] = '|'; board[x][y+1] = '|'; board[x-1][y] = '_'; board[x+1][y] = '_'; /* 192 191 217 218 */ } int main() { drawBoard(); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload