-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
58 lines (41 loc) · 951 Bytes
/
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
49
50
51
52
53
54
55
56
57
58
#include <iostream>
using namespace std;
void draw(bool o[9], bool x[9]);
bool check(bool o[9], bool x[9], int i, string *first, string *second);
int input(int a);
void name(string *a, string *b);
int main(int argc, char *argv[]) {
int a;
string player1;
string player2;
name(&player1, &player2);
bool o[9], x[9];
for (int i = 0; i < 9; i++) {
o[i] = 0;
x[i] = 0;
}
int d = 0;
for (int i = 0; i < 5 && check(o, x, i, &player1, &player2) == false; i++) {
draw(o, x);
cout << player1 << " enter the block of your choice : ";
cin >> a;
// d++;
a = input(a - 1);
o[a] = 1;
d++;
draw(o, x);
if (check(o, x, d, &player1, &player2)) {
return 0;
}
cout << player2 << " enter the block of your choice : ";
cin >> a;
a = input(a - 1);
x[a] = 1;
d++;
draw(o, x);
if (check(o, x, d, &player1, &player2)) {
return 0;
}
}
return 0;
}