sa case 1: logical error ata ako nag kamali di ko na ma figure out
#include <iostream>
#include <random>
using namespace std;
const int board = 5;
struct box {
int bomb;
int hmbombs;// hm = how many
int row,column;
};
int main() {
int num;
box bomb[board][board];
int row,column;
int hmbombs;
bool isRevealed;
cout << "MINE GAME" << endl;
cout << "1. Play\n";
cout << "2. Tutorial\n";
cin >> num;
cout << endl;
switch (num) {
case 1:
cout << "Enter number of bombs (1-3): ";
cin >> hmbombs;
if (hmbombs > 3){
cout << "Invalid number of bombs." << endl;
break;
}
for (int n = 0; n < hmbombs; ++n) {
int randRow = rand() % board;
int randCol = rand() % board;
bomb[randRow][randCol].bomb;
}
do{
cout << " 1 2 3 4 5" << endl;
for (int i = 0; i < board; ++i) {
cout << i + 1 << " ";
for (int j = 0; j < board; ++j) {
if (bomb[j].bomb == board ) {
if (isRevealed) {
cout << "* ";
isRevealed = false;
break;
} else {
cout << "_ ";
}
} else {
cout << ". ";
}
}
cout << endl;
}
cout << "Enter choice" << endl << "row: ";
cin >> row;
if (row > 5) {
cout << "Invalid number" << endl;
continue;
}
cout << "column: ";
cin >> column;
if (column > 5 ) {
cout << "Invalid number" << endl;
continue;
}
cout << endl;
} while (true);
break;
case 2:
cout << "------------------------------ MINE GAME------------------------------"<< endl;
cout << "This game challenges players to strategically uncover tiles on a grid" << endl
<<"while avoiding mines.Each revealed tile displays nearby mine counts,"<<endl
<< "and successful moves increase the player's score multiplier. "<<endl
<<"However, hitting a mine results in immediate loss." << endl;
break;
default:
cout << "Invalid option." << endl;
break;
}
return 0;
}
#include <iostream>
#include <random>
using namespace std;
const int board = 5;
struct box {
int bomb;
int hmbombs;// hm = how many
int row,column;
};
int main() {
int num;
box bomb[board][board];
int row,column;
int hmbombs;
bool isRevealed;
cout << "MINE GAME" << endl;
cout << "1. Play\n";
cout << "2. Tutorial\n";
cin >> num;
cout << endl;
switch (num) {
case 1:
cout << "Enter number of bombs (1-3): ";
cin >> hmbombs;
if (hmbombs > 3){
cout << "Invalid number of bombs." << endl;
break;
}
for (int n = 0; n < hmbombs; ++n) {
int randRow = rand() % board;
int randCol = rand() % board;
bomb[randRow][randCol].bomb;
}
do{
cout << " 1 2 3 4 5" << endl;
for (int i = 0; i < board; ++i) {
cout << i + 1 << " ";
for (int j = 0; j < board; ++j) {
if (bomb[j].bomb == board ) {
if (isRevealed) {
cout << "* ";
isRevealed = false;
break;
} else {
cout << "_ ";
}
} else {
cout << ". ";
}
}
cout << endl;
}
cout << "Enter choice" << endl << "row: ";
cin >> row;
if (row > 5) {
cout << "Invalid number" << endl;
continue;
}
cout << "column: ";
cin >> column;
if (column > 5 ) {
cout << "Invalid number" << endl;
continue;
}
cout << endl;
} while (true);
break;
case 2:
cout << "------------------------------ MINE GAME------------------------------"<< endl;
cout << "This game challenges players to strategically uncover tiles on a grid" << endl
<<"while avoiding mines.Each revealed tile displays nearby mine counts,"<<endl
<< "and successful moves increase the player's score multiplier. "<<endl
<<"However, hitting a mine results in immediate loss." << endl;
break;
default:
cout << "Invalid option." << endl;
break;
}
return 0;
}