Board with array

http://d.yimg.com/hd/answers/i/675e8f55fbfe4241bd8608794c30406f_A.png?a=answers&mr=0&x=1384732009&s=abe4ccb547eed08bbad5964422af74b7


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

Here's my code:

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
  #include <iostream>
    #include <windows.h>
    #include <string>
    #include <cmath>
    #include <stdio.h>

    #include <limits>
    #include <time.h>
    #include <iomanip>

    using namespace 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";
    }
Topic archived. No new replies allowed.