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
|
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <limits>
using std::cout;
using std::cin;
using std::endl;
char a[] = {'|','_','|','_','|','_','|','_','|','_','|','_','|','_','|'};
char b[] = {'|','1','|','2','|','3','|','4','|','5','|','6','|','7','|'};
char board[6][7];
void print_board()
{
//Clears the screen
system("cls");
int i, j = 0;
cout << " ";
for( j = 0; j<15; j++)
cout << b[j];
cout << endl;
for ( i=0; i<6; i++)
{
cout << i+1;
cout << '|';
for (j = 0; j < 7; j++)
cout << board[i][j] << '|';
cout << endl;
}
}
int main()
{
int i, j, k = 0;
int row;
int column;
int gameover = 0;
//Build the board
for (i=0; i<6; i++)
for (j=0; j<7; j++)
board[i][j] = '_';
char player='2'; /* Keeps track of who's playing */
/* Loop through this block until the game ends */
while(! gameover)
{
int row, column;
//Calls the print board method
print_board();
/* Switch players */
if(player == '1')
player='2';
else
player='1';
/* Print a message for the player */
cout << endl << "Player " << player << "'s turn:" << endl;
/* Read two values from the keyboard */
cout << "X:";
cin >> column;
cout << "Y:";
cin >> row;
/* Change the game board */
board[row-1][column-1]=player;
cout << "Player " << player << " wins!" << endl;
gameover = 1;
}
*/
k++;
if( k == 42)
gameover = 1;
cout << endl;
}
cout << "Game Over" <<endl;
system("pause");
return 0;
}
|