#include <iostream>
using namespace std;
int main()
{
//declares selections on the board
char box1('1'
;
char box2('2'
;
char box3('3'
;
char box4('4'
;
char box5('5'
;
char box6('6'
;
char box7('7'
;
char box8('8'
;
char box9('9'
;
char player2icon('O'
;
char playericon('X'
; //the players icon(x or o)
char player2input;
char playerinput; //what the player inputs(1-9)
bool go;
go = true;
while(go = true)
{
//draws the board
cout<<box1<<"|"<<box2<<"|"<<box3<<endl;
cout<<"-+-+-"<<endl;
cout<<box4<<"|"<<box5<<"|"<<box6<<endl;
cout<<"-+-+-"<<endl;
cout<<box7<<"|"<<box8<<"|"<<box9<<endl;
cout<<"X:";
cin>>playerinput;//player 1 input
cout<<endl;
//checks for valid answer(and checks the answer)
if(playerinput == '1' && box1 == '1'
{
box1 = playericon;
}
else if(playerinput == '2' && box2 == '2'
{
box2 = playericon;
}
if(playerinput == '3' && box3 == '3'
{
box3 = playericon;
}
else if(playerinput == '4' && box4 == '4'
{
box4 = playericon;
}
if(playerinput == '5' && box5 == '5'
{
box5 = playericon;
}
else if(playerinput == '6' && box6 == '6'
{
box6 = playericon;
}
if(playerinput == '7' && box7 == '7'
{
box7 = playericon;
}
else if(playerinput == '8' && box8 == '8'
{
box8 = playericon;
}
else if(playerinput == '9' && box9 == '9'
{
box9 = playericon;
}
cout<<box1<<"|"<<box2<<"|"<<box3<<endl;
cout<<"-+-+-"<<endl;
cout<<box4<<"|"<<box5<<"|"<<box6<<endl;
cout<<"-+-+-"<<endl;
cout<<box7<<"|"<<box8<<"|"<<box9<<endl;
cout<<"O:";
cin>>player2input;//player 2 input
cout<<endl;
//checks for valid answer(and checks the answer)
if(player2input == '1' && box1 == '1'
{
box1 = player2icon;
}
else if(player2input == '2' && box2 == '2'
{
box2 = player2icon;
}
if(player2input == '3' && box3 == '3'
{
box3 = player2icon;
}
else if(player2input == '4' && box4 == '4'
{
box4 = player2icon;
}
if(player2input == '5' && box5 == '5'
{
box5 = player2icon;
}
else if(player2input == '6' && box6 == '6'
{
box6 = player2icon;
}
if(player2input == '7' && box7 == '7'
{
box7 = player2icon;
}
else if(player2input == '8' && box8 == '8'
{
box8 = player2icon;
}
else if(player2input == '9' && box9 == '9'
{
box9 = player2icon;
}
if(box1==box5&&box9==box5)
{break;}
if(box1==box2&&box3==box2)
{break;}
if(box1==box4&&box4==box7)
{break;}
if(box7==box8&&box9==box
{break;}
if(box2==box5&&box8==box2)
{break;}
if(box3==box7&&box7==box5)
{break;}
if(box1==box4&&box7==box4)
{break;}
if(box3==box6&&box6==box9)
{break;}
}
if(playericon>player2icon)cout<<playericon<<" WINS!!";
else if(player2icon>playericon )cout<<playericon<<"WINS!!";
char f;
cin>>f;
}
#include <iostream>
#include <stdlib.h>
using namespace std;
int main()
{
//declares selections on the board
char box1('1'
,box2('2'
,box3('3'
,box4('4'
,box5('5'
,box6('6'
,box7('7'
,box8('8'
,box9('9'
;
char player2icon('O'
;
char playericon('X'
; //the players icon(x or o)
char player2input;
char playerinput; //what the player inputs(1-9)
bool go;
go = true;
while(go = true)
{
//draws the board
system("CLS");
cout<<box1<<"|"<<box2<<"|"<<box3<<endl;
cout<<"-+-+-"<<endl;
cout<<box4<<"|"<<box5<<"|"<<box6<<endl;
cout<<"-+-+-"<<endl;
cout<<box7<<"|"<<box8<<"|"<<box9<<endl;
cout<<"X:";
cin>>playerinput;//player 1 input
cout<<endl;
//checks for valid answer(and checks the answer)
if(playerinput == '1' && box1 == '1'
{
box1 = playericon;
}
else if(playerinput == '2' && box2 == '2'
{
box2 = playericon;
}
if(playerinput == '3' && box3 == '3'
{
box3 = playericon;
}
else if(playerinput == '4' && box4 == '4'
{
box4 = playericon;
}
if(playerinput == '5' && box5 == '5'
{
box5 = playericon;
}
else if(playerinput == '6' && box6 == '6'
{
box6 = playericon;
}
if(playerinput == '7' && box7 == '7'
{
box7 = playericon;
}
else if(playerinput == '8' && box8 == '8'
{
box8 = playericon;
}
else if(playerinput == '9' && box9 == '9'
{
box9 = playericon;
}
if(box1==box5&&box9==box5)
{break;}
if(box1==box2&&box3==box2)
{break;}
if(box1==box4&&box4==box7)
{break;}
if(box7==box8&&box9==box
{break;}
if(box2==box5&&box8==box2)
{break;}
if(box3==box7&&box7==box5)
{break;}
if(box1==box4&&box7==box4)
{break;}
if(box3==box6&&box6==box9)
{break;}
system("CLS");
cout<<box1<<"|"<<box2<<"|"<<box3<<endl;
cout<<"-+-+-"<<endl;
cout<<box4<<"|"<<box5<<"|"<<box6<<endl;
cout<<"-+-+-"<<endl;
cout<<box7<<"|"<<box8<<"|"<<box9<<endl;
cout<<"O:";
cin>>player2input;//player 2 input
cout<<endl;
//checks for valid answer(and checks the answer)
if(player2input == '1' && box1 == '1'
{
box1 = player2icon;
}
else if(player2input == '2' && box2 == '2'
{
box2 = player2icon;
}
if(player2input == '3' && box3 == '3'
{
box3 = player2icon;
}
else if(player2input == '4' && box4 == '4'
{
box4 = player2icon;
}
if(player2input == '5' && box5 == '5'
{
box5 = player2icon;
}
else if(player2input == '6' && box6 == '6'
{
box6 = player2icon;
}
if(player2input == '7' && box7 == '7'
{
box7 = player2icon;
}
else if(player2input == '8' && box8 == '8'
{
box8 = player2icon;
}
else if(player2input == '9' && box9 == '9'
{
box9 = player2icon;
}
if(box1==box5&&box9==box5)
{break;}
if(box1==box2&&box3==box2)
{break;}
if(box1==box4&&box4==box7)
{break;}
if(box7==box8&&box9==box
{break;}
if(box2==box5&&box8==box2)
{break;}
if(box3==box7&&box7==box5)
{break;}
if(box1==box4&&box7==box4)
{break;}
if(box3==box6&&box6==box9)
{break;}
}
if(playericon>player2icon)cout<<playericon<<" WINS!!";
else if(player2icon>playericon )cout<<playericon<<"WINS!!";
char f;
cin>>f;
}
#include <iostream>
using namespace std;
int main()
{
//declares selections on the board
char box1('1'
;
char box2('2'
;
char box3('3'
;
char box4('4'
;
char box5('5'
;
char box6('6'
;
char box7('7'
;
char box8('8'
;
char box9('9'
;
char player2icon('O'
;
char playericon('X'
; //the players icon(x or o)
char player2input;
char playerinput; //what the player inputs(1-9)
bool go;
go = true;
while(go = true)
{
//draws the board
cout<<box1<<"|"<<box2<<"|"<<box3<<endl;
cout<<"-+-+-"<<endl;
cout<<box4<<"|"<<box5<<"|"<<box6<<endl;
cout<<"-+-+-"<<endl;
cout<<box7<<"|"<<box8<<"|"<<box9<<endl;
cout<<"X:";
cin>>playerinput;//player 1 input
cout<<endl;
//checks for valid answer(and checks the answer)
if(playerinput == '1' && box1 == '1'
{
box1 = playericon;
}
else if(playerinput == '2' && box2 == '2'
{
box2 = playericon;
}
if(playerinput == '3' && box3 == '3'
{
box3 = playericon;
}
else if(playerinput == '4' && box4 == '4'
{
box4 = playericon;
}
if(playerinput == '5' && box5 == '5'
{
box5 = playericon;
}
else if(playerinput == '6' && box6 == '6'
{
box6 = playericon;
}
if(playerinput == '7' && box7 == '7'
{
box7 = playericon;
}
else if(playerinput == '8' && box8 == '8'
{
box8 = playericon;
}
else if(playerinput == '9' && box9 == '9'
{
box9 = playericon;
}
cout<<box1<<"|"<<box2<<"|"<<box3<<endl;
cout<<"-+-+-"<<endl;
cout<<box4<<"|"<<box5<<"|"<<box6<<endl;
cout<<"-+-+-"<<endl;
cout<<box7<<"|"<<box8<<"|"<<box9<<endl;
cout<<"O:";
cin>>player2input;//player 2 input
cout<<endl;
//checks for valid answer(and checks the answer)
if(player2input == '1' && box1 == '1'
{
box1 = player2icon;
}
else if(player2input == '2' && box2 == '2'
{
box2 = player2icon;
}
if(player2input == '3' && box3 == '3'
{
box3 = player2icon;
}
else if(player2input == '4' && box4 == '4'
{
box4 = player2icon;
}
if(player2input == '5' && box5 == '5'
{
box5 = player2icon;
}
else if(player2input == '6' && box6 == '6'
{
box6 = player2icon;
}
if(player2input == '7' && box7 == '7'
{
box7 = player2icon;
}
else if(player2input == '8' && box8 == '8'
{
box8 = player2icon;
}
else if(player2input == '9' && box9 == '9'
{
box9 = player2icon;
}
if(box1==box5&&box9==box5)
{break;}
if(box1==box2&&box3==box2)
{break;}
if(box1==box4&&box4==box7)
{break;}
if(box7==box8&&box9==box
{break;}
if(box2==box5&&box8==box2)
{break;}
if(box3==box7&&box7==box5)
{break;}
if(box1==box4&&box7==box4)
{break;}
if(box3==box6&&box6==box9)
{break;}
}
if(playericon>player2icon)cout<<playericon<<" WINS!!";
else if(player2icon>playericon )cout<<playericon<<"WINS!!";
char f;
cin>>f;
}
Copyright © 2026, NextGenUpdate.
All Rights Reserved.