SlideShare a Scribd company logo
1 of 5
#include<iostream>
usingnamespace std;
char turn='X';
bool d=f;
classtictacgame
{
public:
char a[3][3]={{'1','2','3'},{'4','5','6'},{'7','8','9'}};
intch, ro , co;
intinterface()
{
system("cls");
cout<<"n nnt t t "<<"Welcome"<<endl;
cout<<"n t t t"<<"TTT(tictac toc) "<<endl;
cout<<"t PLAYER 1's X"<<endl<<"tPLAYER2's 0"<<endl;
cout<<"t t | | n";
cout<<"t t "<<a[0][0]<<" | "<<a[0][1]<<" | "<<a[0][2]<<" "<<endl;
cout<<"t t_____|_____|_____n";
cout<<"t t | | n";
cout<<"t t "<<a[1][0]<<" | "<<a[1][1]<<" | "<<a[1][2]<<" "<<endl;
cout<<"t t_____|_____|_____n";
cout<<"t t | | n";
cout<<"t t "<<a[2][0]<<" | "<<b[2][1]<<" | "<<a[2][2]<<" "<<endl;
cout<<"t t | | n";
}
voidplayer()
{
if(turn=='X')
cout<<"n t enterplayer1[X] turn:";
else if(turn=='0')
cout<<"n t enterplayer2[0] turn:";
cin>>ch;
switch(ch)
{
case 1:
ro=0;
co=0;
break;
case 2:
ro=0;
co=1;
break;
case 3:
ro=0;
co=2;
break;
case 4:
ro=1;
co=0;
break;
case 5:
ro=1;
co=1;
break;
case 6:
ro=1;
co=2;
break;
case 7:
ro=2;
co=0;
break;
case 8:
ro=2;
co=1;
break;
case 9:
ro=2;
co=2;
break;
default:
cout<<"t InvalidChoice";
}
if(turn=='X' && a[ro][co]!='X' && a[ro][co]!='0')
{
a[ro][co]='X';
turn='0';
}
else if(turn=='0' && a[ro][co]!='X' && a[ro][co]!='0')
{
a[ro][co]='0';
turn='X';
}
else
{
cout<<"t NOSPACE Try Again";
player();
}
board();
}
bool gameover()
{
//game wins
for(inti=0;i<3;i++)
if(a[0][0] ==a[0][1] && a[0][0] ==a[0][2] || a[1][0] == a[1][1] && a[1][0] ==a[1][2] || a
a[2][0] == a[2][1] && a[2][0] ==a[2][2] || a[0][0] == a[1][1] && a[0][0] ==a[2][2] || a[0][2] == a[1][1]
&& a[0][2] ==a[2][0])
returnfalse;
//empty
for(inti=0;i<3; i++)
for(intj=0; j<3; j++)
if(a[i][j]!='X'&& a[i][j]!='0')
returntrue;
//draw
draw=true;
returnfalse;
}
};
main()
{
tictacgame g;
while(t.gameover())
{
g.board();
g.player();
g.board();
g.gameover();
}
if(turn=='X'&& draw== false)
{
cout<<"Player2[0] Wins......Congratulations"<<endl;
}
if(turn=='0' && draw== false)
{
cout<<"Player1[X] Wins......Congratulations"<<endl;
}
{
cout<<"GAME OVER";
}
}

More Related Content

What's hot

strace for Perl Mongers
strace for Perl Mongersstrace for Perl Mongers
strace for Perl MongersNaosuke Yokoe
 
Using browser() in R
Using browser() in RUsing browser() in R
Using browser() in RLeon Kim
 
Python and rust 2018 pythonkorea jihun
Python and rust 2018 pythonkorea jihunPython and rust 2018 pythonkorea jihun
Python and rust 2018 pythonkorea jihunJIHUN KIM
 
Simple php backdoor_by_dk
Simple php backdoor_by_dkSimple php backdoor_by_dk
Simple php backdoor_by_dkStan Adrian
 
Programação completa e perfeira
Programação completa e perfeiraProgramação completa e perfeira
Programação completa e perfeiraMagno Rodrigues
 
자바스터디 4
자바스터디 4자바스터디 4
자바스터디 4jangpd007
 
Automated tests - facts and myths
Automated tests - facts and mythsAutomated tests - facts and myths
Automated tests - facts and mythsWojciech Sznapka
 
An (abridged) Ruby Plumber's Guide to *nix
An (abridged) Ruby Plumber's Guide to *nixAn (abridged) Ruby Plumber's Guide to *nix
An (abridged) Ruby Plumber's Guide to *nixEleanor McHugh
 
Client-side Storage 
Client-side Storage Client-side Storage 
Client-side Storage Tobias Wolf
 
Combine vs RxSwift
Combine vs RxSwiftCombine vs RxSwift
Combine vs RxSwiftshark-sea
 

What's hot (20)

strace for Perl Mongers
strace for Perl Mongersstrace for Perl Mongers
strace for Perl Mongers
 
Using browser() in R
Using browser() in RUsing browser() in R
Using browser() in R
 
Clojure入門
Clojure入門Clojure入門
Clojure入門
 
Elixir @ Paris.rb
Elixir @ Paris.rbElixir @ Paris.rb
Elixir @ Paris.rb
 
project3
project3project3
project3
 
Python and rust 2018 pythonkorea jihun
Python and rust 2018 pythonkorea jihunPython and rust 2018 pythonkorea jihun
Python and rust 2018 pythonkorea jihun
 
Lalal
LalalLalal
Lalal
 
Php&redis presentation
Php&redis presentationPhp&redis presentation
Php&redis presentation
 
RG講義_SSH
RG講義_SSHRG講義_SSH
RG講義_SSH
 
TCP/IP Exercises
TCP/IP ExercisesTCP/IP Exercises
TCP/IP Exercises
 
Hello c
Hello cHello c
Hello c
 
clonehd01
clonehd01clonehd01
clonehd01
 
Simple php backdoor_by_dk
Simple php backdoor_by_dkSimple php backdoor_by_dk
Simple php backdoor_by_dk
 
C code
C codeC code
C code
 
Programação completa e perfeira
Programação completa e perfeiraProgramação completa e perfeira
Programação completa e perfeira
 
자바스터디 4
자바스터디 4자바스터디 4
자바스터디 4
 
Automated tests - facts and myths
Automated tests - facts and mythsAutomated tests - facts and myths
Automated tests - facts and myths
 
An (abridged) Ruby Plumber's Guide to *nix
An (abridged) Ruby Plumber's Guide to *nixAn (abridged) Ruby Plumber's Guide to *nix
An (abridged) Ruby Plumber's Guide to *nix
 
Client-side Storage 
Client-side Storage Client-side Storage 
Client-side Storage 
 
Combine vs RxSwift
Combine vs RxSwiftCombine vs RxSwift
Combine vs RxSwift
 

Similar to Rabia

Programa Sumar y Multiplicar
Programa Sumar y MultiplicarPrograma Sumar y Multiplicar
Programa Sumar y MultiplicarAnais Rodriguez
 
Add an interactive command line to your C++ application
Add an interactive command line to your C++ applicationAdd an interactive command line to your C++ application
Add an interactive command line to your C++ applicationDaniele Pallastrelli
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloadingkinan keshkeh
 
Laporan Praktikum 1 dev c++
Laporan Praktikum 1 dev c++Laporan Praktikum 1 dev c++
Laporan Praktikum 1 dev c++phoe3
 
c++ project on restaurant billing
c++ project on restaurant billing c++ project on restaurant billing
c++ project on restaurant billing Swakriti Rathore
 
ch9_additional.ppt
ch9_additional.pptch9_additional.ppt
ch9_additional.pptLokeshK66
 
pa-pe-pi-po-pure Python Text Processing
pa-pe-pi-po-pure Python Text Processingpa-pe-pi-po-pure Python Text Processing
pa-pe-pi-po-pure Python Text ProcessingRodrigo Senra
 
RAILWAY RESERWATION PROJECT PROGRAM
RAILWAY RESERWATION PROJECT PROGRAMRAILWAY RESERWATION PROJECT PROGRAM
RAILWAY RESERWATION PROJECT PROGRAMKrishna Raj
 
Степан Кольцов — Rust — лучше, чем C++
Степан Кольцов — Rust — лучше, чем C++Степан Кольцов — Rust — лучше, чем C++
Степан Кольцов — Rust — лучше, чем C++Yandex
 
Bank management system project in c++ with graphics
Bank management system project in c++ with graphicsBank management system project in c++ with graphics
Bank management system project in c++ with graphicsVtech Academy of Computers
 
201412 seccon2014 オンライン予選(英語) write-up
201412 seccon2014 オンライン予選(英語) write-up201412 seccon2014 オンライン予選(英語) write-up
201412 seccon2014 オンライン予選(英語) write-up恵寿 東
 
Start with the inclusion of libraries#include iostream .docx
 Start with the inclusion of libraries#include iostream .docx Start with the inclusion of libraries#include iostream .docx
Start with the inclusion of libraries#include iostream .docxMARRY7
 

Similar to Rabia (20)

Hospital management
Hospital managementHospital management
Hospital management
 
Hospital management
Hospital managementHospital management
Hospital management
 
Programa Sumar y Multiplicar
Programa Sumar y MultiplicarPrograma Sumar y Multiplicar
Programa Sumar y Multiplicar
 
Project in programming
Project in programmingProject in programming
Project in programming
 
Codes on structures
Codes on structuresCodes on structures
Codes on structures
 
New
NewNew
New
 
Add an interactive command line to your C++ application
Add an interactive command line to your C++ applicationAdd an interactive command line to your C++ application
Add an interactive command line to your C++ application
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
 
Laporan Praktikum 1 dev c++
Laporan Praktikum 1 dev c++Laporan Praktikum 1 dev c++
Laporan Praktikum 1 dev c++
 
c++ project on restaurant billing
c++ project on restaurant billing c++ project on restaurant billing
c++ project on restaurant billing
 
ch9_additional.ppt
ch9_additional.pptch9_additional.ppt
ch9_additional.ppt
 
C programs
C programsC programs
C programs
 
pa-pe-pi-po-pure Python Text Processing
pa-pe-pi-po-pure Python Text Processingpa-pe-pi-po-pure Python Text Processing
pa-pe-pi-po-pure Python Text Processing
 
RAILWAY RESERWATION PROJECT PROGRAM
RAILWAY RESERWATION PROJECT PROGRAMRAILWAY RESERWATION PROJECT PROGRAM
RAILWAY RESERWATION PROJECT PROGRAM
 
Степан Кольцов — Rust — лучше, чем C++
Степан Кольцов — Rust — лучше, чем C++Степан Кольцов — Rust — лучше, чем C++
Степан Кольцов — Rust — лучше, чем C++
 
Bank management system project in c++ with graphics
Bank management system project in c++ with graphicsBank management system project in c++ with graphics
Bank management system project in c++ with graphics
 
201412 seccon2014 オンライン予選(英語) write-up
201412 seccon2014 オンライン予選(英語) write-up201412 seccon2014 オンライン予選(英語) write-up
201412 seccon2014 オンライン予選(英語) write-up
 
Code em Poker
Code em PokerCode em Poker
Code em Poker
 
AI For Texam Hold'em poker
AI For Texam Hold'em pokerAI For Texam Hold'em poker
AI For Texam Hold'em poker
 
Start with the inclusion of libraries#include iostream .docx
 Start with the inclusion of libraries#include iostream .docx Start with the inclusion of libraries#include iostream .docx
Start with the inclusion of libraries#include iostream .docx
 

More from university of Gujrat, pakistan

More from university of Gujrat, pakistan (20)

Change management
Change management Change management
Change management
 
Latest Trends in Digital Marketing
Latest Trends in Digital MarketingLatest Trends in Digital Marketing
Latest Trends in Digital Marketing
 
Dark web (2)
Dark web (2)Dark web (2)
Dark web (2)
 
Code of ethics and professional conduct (1)
Code of ethics and professional conduct (1)Code of ethics and professional conduct (1)
Code of ethics and professional conduct (1)
 
Certification accreditation and licensure (1)
Certification accreditation and licensure (1)Certification accreditation and licensure (1)
Certification accreditation and licensure (1)
 
biggest technology trends
biggest technology trendsbiggest technology trends
biggest technology trends
 
Freedom of information (1)
Freedom of information (1)Freedom of information (1)
Freedom of information (1)
 
Individual cognition ppt (1)
Individual cognition ppt (1)Individual cognition ppt (1)
Individual cognition ppt (1)
 
Top 10 highest (1)
Top 10 highest (1)Top 10 highest (1)
Top 10 highest (1)
 
creativity and imagination
creativity and imagination creativity and imagination
creativity and imagination
 
Brainstorming 078 (1)
Brainstorming 078 (1)Brainstorming 078 (1)
Brainstorming 078 (1)
 
speeh-artificial intelligemce
speeh-artificial intelligemce speeh-artificial intelligemce
speeh-artificial intelligemce
 
Pp dealing with problem complexity (1)
Pp dealing with problem complexity (1)Pp dealing with problem complexity (1)
Pp dealing with problem complexity (1)
 
Motivation
MotivationMotivation
Motivation
 
Vision of artificial intelligence (1)
Vision of artificial intelligence (1)Vision of artificial intelligence (1)
Vision of artificial intelligence (1)
 
Entrepreneurship (1)
Entrepreneurship (1)Entrepreneurship (1)
Entrepreneurship (1)
 
Role of professional societies
Role of professional societiesRole of professional societies
Role of professional societies
 
Dealing with culticultural environment (1)
Dealing with culticultural environment (1)Dealing with culticultural environment (1)
Dealing with culticultural environment (1)
 
Dealing with problem complexity (1)
Dealing with problem complexity (1)Dealing with problem complexity (1)
Dealing with problem complexity (1)
 
cyber security and cyber crime
cyber security and cyber crime cyber security and cyber crime
cyber security and cyber crime
 

Recently uploaded

5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 

Recently uploaded (20)

5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 

Rabia

  • 1. #include<iostream> usingnamespace std; char turn='X'; bool d=f; classtictacgame { public: char a[3][3]={{'1','2','3'},{'4','5','6'},{'7','8','9'}}; intch, ro , co; intinterface() { system("cls"); cout<<"n nnt t t "<<"Welcome"<<endl; cout<<"n t t t"<<"TTT(tictac toc) "<<endl; cout<<"t PLAYER 1's X"<<endl<<"tPLAYER2's 0"<<endl; cout<<"t t | | n"; cout<<"t t "<<a[0][0]<<" | "<<a[0][1]<<" | "<<a[0][2]<<" "<<endl; cout<<"t t_____|_____|_____n"; cout<<"t t | | n"; cout<<"t t "<<a[1][0]<<" | "<<a[1][1]<<" | "<<a[1][2]<<" "<<endl; cout<<"t t_____|_____|_____n"; cout<<"t t | | n"; cout<<"t t "<<a[2][0]<<" | "<<b[2][1]<<" | "<<a[2][2]<<" "<<endl; cout<<"t t | | n"; } voidplayer() { if(turn=='X')
  • 2. cout<<"n t enterplayer1[X] turn:"; else if(turn=='0') cout<<"n t enterplayer2[0] turn:"; cin>>ch; switch(ch) { case 1: ro=0; co=0; break; case 2: ro=0; co=1; break; case 3: ro=0; co=2; break; case 4: ro=1; co=0; break; case 5: ro=1; co=1; break; case 6: ro=1; co=2;
  • 3. break; case 7: ro=2; co=0; break; case 8: ro=2; co=1; break; case 9: ro=2; co=2; break; default: cout<<"t InvalidChoice"; } if(turn=='X' && a[ro][co]!='X' && a[ro][co]!='0') { a[ro][co]='X'; turn='0'; } else if(turn=='0' && a[ro][co]!='X' && a[ro][co]!='0') { a[ro][co]='0'; turn='X'; } else {
  • 4. cout<<"t NOSPACE Try Again"; player(); } board(); } bool gameover() { //game wins for(inti=0;i<3;i++) if(a[0][0] ==a[0][1] && a[0][0] ==a[0][2] || a[1][0] == a[1][1] && a[1][0] ==a[1][2] || a a[2][0] == a[2][1] && a[2][0] ==a[2][2] || a[0][0] == a[1][1] && a[0][0] ==a[2][2] || a[0][2] == a[1][1] && a[0][2] ==a[2][0]) returnfalse; //empty for(inti=0;i<3; i++) for(intj=0; j<3; j++) if(a[i][j]!='X'&& a[i][j]!='0') returntrue; //draw draw=true; returnfalse; } }; main() { tictacgame g; while(t.gameover())
  • 5. { g.board(); g.player(); g.board(); g.gameover(); } if(turn=='X'&& draw== false) { cout<<"Player2[0] Wins......Congratulations"<<endl; } if(turn=='0' && draw== false) { cout<<"Player1[X] Wins......Congratulations"<<endl; } { cout<<"GAME OVER"; } }