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
|
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
void generate_board();
void display_board();
void get_move_from_user();
void make_move();
int main()
{
generate_board();
display_board();
get_move_from_user();
return 0;
}
void generate_board()
{
const int SIZE = 25;
const int MIN_VALUE = 0;
const int MAX_VALUE = 24;
int r;
char tmp;
char board[SIZE] = { ' ', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X'};
unsigned seed = time(0);
srand(seed);
for (int i = 0; i < SIZE; i++)
{
r = (rand() % (MAX_VALUE - MIN_VALUE + 1)) + MIN_VALUE;
tmp = board[i];
board[i] = board[r];
board[r] = tmp;
}
}
void display_board()
{
for (int i = 0; i < 25; i++)
{
cout << board[i] << " ";
if (i % 5 == 4)
cout << endl;
}
}
void get_move_from_user()
{
char move;
cout << "enter a character to make a move: ";
cin >> move;
while (move != 'w' && move != 'a' && move != 's' && move != 'd')
{
cout << "That is not a valid input, please try again: ";
cin >> move;
}
}
void make_move()
{
}
|