123456789101112131415161718192021222324252627282930313233343536373839
int main() { int grid[9][9]; initGrid(grid); printBoard(grid); return 0; } void initGrid(int grid[][9]) { for(int col=0; col<10; col++) //Outer column loop { for(int row=0; row<10; row++) //Inner row loop { grid[col][row]=0; } } } void printBoard(int grid[][9]) { cout << " 0|1|2|3|4|5|6|7|8|9" << endl << endl; for(int i=0; i<10; i++) //column loop { for(int j=0; j<10; j++) //row loop { if(j==0) { cout << i << " " ; //print row number and spaces before new row } cout << grid[i][j] ; if(j!=9) { cout << "|"; } } cout << endl; //new line at end of column } }
int grid[10][10];