Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <windows.h>
- using namespace std;
- bool waiting=false;
- const unsigned int DIM1 = 3;
- const unsigned int DIM2 = 5;
- bool next_step=true;
- char ary[DIM1][DIM2]={{'E','E','E'},{'E','E','E'},{'E','E','E'}};
- void print_array(){
- for (int i = 0; i < DIM1; i++) {
- for (int j = 0; j < DIM2; j++) {
- cout<< ary[i][j];
- }
- cout << endl;
- }
- }
- void step2(){
- if (!(ary[0][0]==ary[1][0] and ary[1][0]==ary[2][0] and ary[0][0]=='X')) {
- waiting=true;
- system("cls");
- int x,y;
- x=rand()%3;
- y=rand()%3;
- if (ary[x][y]!='X'){
- ary[y][x]='O';
- system("cls");
- print_array();
- }
- else{
- step2();
- }
- waiting=false;
- }
- }
- void step(){
- waiting=true;
- int x,y;
- cout<<"cell.x"<<endl;
- cin>>x;
- cout<<"cell.y"<<endl;
- cin>>y;
- system("cls");
- ary[y-1][x-1]='X';
- print_array();
- if (ary[0][0]==ary[1][0] and ary[1][0]==ary[2][0] and ary[0][0]=='X'){
- next_step=false;
- }
- step2();
- waiting=false;
- }
- int main() {
- while (!(ary[0][0]==ary[1][0] and ary[1][0]==ary[2][0] and ary[0][0]=='X')){
- if (!waiting) {
- print_array();
- step();
- }
- else{
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement