How could I make a board like that one? I know its using arrays but I cant seem to get it done :l
What I want to do with the program is to print something inside the squares, I will do that later tho. thanks
#include <iostream>
#include <windows.h>
#include <string>
#include <cmath>
#include <stdio.h>
#include <limits>
#include <time.h>
#include <iomanip>
usingnamespace std;
int main()
{
int mines=0, X, Y;
int boardm[9][9] = {0}; // Set whole array to zeroes
srand((unsigned)time(0));
//------------------------------- Random mine placement, seems to work.
cout << "Placing Mines.." << endl;
do
{
do
{
X = rand()%9; // get a random row
Y = rand()%9; // get a random column
}while (boardm[X][Y] !=0 ); // do again if a mine is located there already
boardm[X][Y] = 1; // place a mine at location
mines++; // increase mine count
} while (mines < 3); // Keep doing this until we have 99 mines
for(X=0; X<9; X++)
{
for( Y=0; Y<9; Y++)
{
cout << boardm[X][Y] << " "; // Print out Mine Sweeper board
}
cout << endl; // After print a row, do a new line, and start a new row
}
cout << "There are " << mines << " Mines\n\n";
}