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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
|
#include <iostream>
using namespace std;
int player = 0;
char board[8][8] = {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',' ',' ',' ',' ',' ',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '};
void gameboard();
void getmove();
int main();
char choice;
int player1,player2;
int score1 = 0, score2 = 0;
char letter;
void gather_all();
int row, col;
int a;
void gameboard()
{
system("cls");
cout << "player1: " <<score1<<"\t"<< "player2: "<<score2<< endl;
cout<<"+===+===+===+===+===+===+===+===+"<<endl;
for(int i=0;i<8;i++){
cout<<"! ";
for(int j=0;j<8;j++)
cout<<board[i][j]<<" ! ";
cout<<endl<<"+===+===+===+===+===+===+===+===+"<<endl;
}
}
void getmove()
{
int row, col;
if(player <=0)
{
cout<<"P1 enter the block(NUMBERS ONLY!): ";
while(!(cin>>a))
{
cout<<"I SAID NUMBERS ONLY!!!!";
cin.clear();
cin.ignore(1000,'\n');
}
cout<<"Enter S or O(USE CAPITALS ONLY!): ";
cin>>letter;
if(letter == 'S' || letter == 'O')
{
row = (a-1)/8;
col = (a-1)%8;
board[row][col] = letter;
player++;
if(board[0][0] == 'S' && board[0][1] == 'O' && board[0][2] == 'S')
{
score1++;
}
if(score1>0)
{
system("pause");
system("cls");
cout<<"do you want to continue?(y/n)"<<endl;
cin>>choice;
switch (choice)
{
case 'Y':
case 'y':
gather_all();
case 'N':
case 'n':
cout<<"Exiting..";
exit(1);
}
}
}
else
{
cout<<"I SAID CAPITALS ONLY!!!!. ALSO USE S OR O.";
system("pause");
system("cls");
}
}
if(player > 0 )
{
cout<<"P2 enter the block(NUMBERS ONLY!): ";
cin>>a;
cout<<"Enter S or O(USE CAPITALS ONLY!): ";
cin>>letter;
if(letter == 'S' || letter == 'O')
{
row = (a-1)/8;
col = (a-1)%8;
board[row][col] = letter;
player--;
}
else
{
cout<<"I SAID CAPITALS ONLY!!!!. ALSO USE S OR O.\n\n";
system("cls");
}
}
}
void gather_all()
{
gameboard();
while(1)
{
getmove();
gameboard();
}
}
int main()
{
gather_all();
return 0;
}
|