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
|
#include <iostream>
using namespace std;
int main(){
srand(time(NULL));
bool minefield [4][4] = { {false, false, false, false},
{false, false, false, false},
{false, false, false, false},
{false, false, false, false} };
int mines = 4;
while(mines > 0){
int placeMineX, placeMineY;
do {
placeMineX = rand()%4;
placeMineY = rand()%4;
}
while (minefield [placeMineX] [placeMineY] == true);
minefield [placeMineX] [placeMineY] = true;
mines--;
}
cout << "Pick a place to step 0:3 by 0:3 (e.g: 3 1): " << endl;
int x, y;
cin >> x >> y;
if (minefield [y][x]){
cout << "BOOM!" << endl;
} else {
cout << "Lucky guess... " << endl;
}
system (("PAUSE"));
}
| |