#include<iostream>
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<time.h>
using namespace std;
void printBoard();
void fillBoard();
void checkWin();
string board [9][9];
bool gameOver = false;
int main()
{
fillBoard();
printBoard();
}//end of main
void printBoard()
{
cout<<board[0][0]<<" | "<<board[0][1]<<" | "<<board[0][2]<<" "<<board[0][3]<<" | "<<board[0][4]<<" | "<<board[0][5]<<" "<<board[0][6]<<"| "<<board[0][7]<<" | "<<board[0][8]<<endl<<"--------- --------- ---------\n";//1st line
cout<<board[1][0]<<" | "<<board[1][1]<<" | "<<board[1][2]<<" "<<board[1][3]<<" | "<<board[1][4]<<" | "<<board[1][5]<<" "<<board[1][6]<<"| "<<board[1][7]<<" | "<<board[1][8]<<endl<<"--------- --------- ---------\n";//2nd line
cout<<board[2][0]<<" | "<<board[2][1]<<" | "<<board[2][2]<<" "<<board[2][3]<<" | "<<board[2][4]<<" | "<<board[2][5]<<" "<<board[2][6]<<"| "<<board[2][7]<<" | "<<board[2][8]<<endl<<endl<<endl;//3rd line
cout<<board[3][0]<<" | "<<board[3][1]<<" | "<<board[3][2]<<" "<<board[3][3]<<" | "<<board[3][4]<<" | "<<board[3][5]<<" "<<board[3][6]<<"| "<<board[3][7]<<" | "<<board[3][8]<<endl<<"--------- --------- ---------\n";//4th line
cout<<board[4][0]<<" | "<<board[4][1]<<" | "<<board[4][2]<<" "<<board[4][3]<<" | "<<board[4][4]<<" | "<<board[4][5]<<" "<<board[4][6]<<"| "<<board[4][7]<<" | "<<board[4][8]<<endl<<"--------- --------- ---------\n";//5th line
cout<<board[5][0]<<" | "<<board[5][1]<<" | "<<board[5][2]<<" "<<board[5][3]<<" | "<<board[5][4]<<" | "<<board[5][5]<<" "<<board[5][6]<<"| "<<board[5][7]<<" | "<<board[5][8]<<endl<<endl<<endl;//6th line
cout<<board[6][0]<<" | "<<board[6][1]<<" | "<<board[6][2]<<" "<<board[6][3]<<" | "<<board[6][4]<<" | "<<board[6][5]<<" "<<board[6][6]<<"| "<<board[6][7]<<" | "<<board[6][8]<<endl<<"--------- --------- ---------\n";//7th line
cout<<board[7][0]<<" | "<<board[7][1]<<" | "<<board[7][2]<<" "<<board[7][3]<<" | "<<board[7][4]<<" | "<<board[7][5]<<" "<<board[7][6]<<"| "<<board[7][7]<<" | "<<board[7][8]<<endl<<"--------- --------- ---------\n";//8th line
cout<<board[8][0]<<" | "<<board[8][1]<<" | "<<board[8][2]<<" "<<board[8][3]<<" | "<<board[8][4]<<" | "<<board[8][5]<<" "<<board[8][6]<<"| "<<board[8][7]<<" | "<<board[8][8]<<endl<<endl<<endl;//9th line
}//end of printBoard()
void fillBoard()
{
for (int i=0; i<9; i++)
{
for (int j=0; j<9; j++)
{
board [i][j] =('0'-48)+(9*i + j+1);
}
}
}//end of fill Board()
we originally use char board. but char wont let us go past single digit
forcing us to use "string"
the program output this:
☺ | ☻ | ♥ ♦ | ♣ | ♠ | |
--------- --------- ---------
| ♫ | ☼ ►| ◄ | ↕
--------- --------- ---------
‼ | ¶ | § ▬ | ↨ | ↑ ↓| → | ←
∟ | ↔ | ▲ ▼ | | ! "| # | $
--------- --------- ---------
% | & | ' ( | ) | * +| , | -
--------- --------- ---------
. | / | 0 1 | 2 | 3 4| 5 | 6
7 | 8 | 9 : | ; | < =| > | ?
--------- --------- ---------
@ | A | B C | D | E F| G | H
--------- --------- ---------
I | J | K L | M | N O| P | Q
Press any key to continue . . .
suppose to look at this:
1 | 2 | 3 4 | 5 | 6 7| 8 | 9
--------- --------- ---------
10| 11| 12 13| 14| 15 16| 17| 18
--------- --------- ---------
19| 20| 21 22| 23| 24 25| 26| 27
28| 29| 30 31| 32| 33 34| 35| 36
--------- --------- ---------
37| 38| 39 40| 41| 42 43| 44| 45
--------- --------- ---------
46| 47| 48 49| 50| 51 52| 53| 54
55| 56| 57 58| 59| 60 61| 62| 63
--------- --------- ---------
64| 65| 66 67| 68| 69 70| 71| 72
--------- --------- ---------
73| 74| 75 76| 77| 78 79| 80| 81
Press any key to continue . . .
Our teacher told us to use "stringstream"
Can someone explain to me the usage of "stringstream"?
in depth will be better