Last active
March 25, 2021 11:55
-
-
Save CaptainHandyman/924be889c082d63ff970025a1b4dadc2 to your computer and use it in GitHub Desktop.
cross and zero : )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
#define FIRST 'x' | |
#define SECOND '0' | |
char arr[3][3]; | |
void check() { | |
string horizontally, vertically, oblique, _oblique; | |
for (int i = 0; i < 3; i++) { | |
for (int j = 0; j < 3; j++) { | |
horizontally += arr[i][j]; | |
vertically += arr[j][i]; | |
} | |
oblique += arr[i][i]; | |
_oblique += arr[i][2 - i]; | |
if (horizontally == "xxx" || vertically == "xxx" || oblique == "xxx" || | |
_oblique == "xxx") { | |
cout << "FIRST" << endl; | |
break; | |
} | |
if (horizontally == "000" || vertically == "000" || oblique == "000" || | |
_oblique == "000") { | |
cout << "SECOND" << endl; | |
break; | |
} | |
horizontally = ""; | |
vertically = ""; | |
} | |
} | |
int main() { | |
for (int i = 0; i < 3; i++) { | |
for (int j = 0; j < 3; j++) | |
cin >> arr[i][j]; | |
} | |
check(); | |
} | |
/* | |
x x x | |
0 0 0 | |
x x x | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment