repl.it
@JimSkon/

FinishedSilentAtom

C++

No description

fork
loading
Files
  • main.cpp
main.cpp
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
#include <iostream>
using namespace std;

char player(int t) {
  // if t is even, return "X"
  // otherwise return "0"
  if (t%2==0) return('X');
  return('O');
}

void printTTT(char b[][3]){
  for (int row=0; row<3; row++){
    for (int col=0; col<3; col++) {
      cout << b[row][col];
      if (col<2) {
        cout << "|";
      }
    }
    if (row<2){
      cout << endl << "-----" << endl;
    }  
  }
  cout << endl;
}
void doMove(char b[][3], int t){
  int r=-1, c=0;
  // Check if in range
  while (r<0 || r>2 || c<0 || c>2 || b[r][c]!=' ' ) {
    cout << "Enter your move player " << player(t) << ": ";
    cin >> r >> c;
  }
  b[r][c]=player(t);
}

bool winCheck(char b[][3]) {

}
int main() {
  char ttt[3][3]={' ',' ',' ',' ',' ',' ',' ',' ',' '};
  int turn=0;
  while (turn<9) {
    printTTT(ttt);
    doMove(ttt,turn);
    turn++;
  }


}