Basic minesweeper. Bomb counter function not working. : I've been working on some code for a basic minesweeper program and at this point I'm complacently lost. The numbers around the bombs wont generate properly and there doesn't even seem to be a pattern to whats going wrong. I need help with finding a way to fix this issue without having to re-wright my enter program. my teacher cant figure out a way to help me and suggests that I use what i have to make a luck based game sense its due Tuesday. Please help.



    #include <iostream>
    #include <fstream>
    #include <string>
    #include <cstdlib>
    #include <conio.h>
    #include <windows.h>
    #include <ctime>
    using namespace std;
    int main()
    {
    int GameBoard [9] [9] = { };
    int BombTracker [20] = { };
    srand(time(0));
    for (int c = 0; c <= 10; c++ ) //generates 10 bombs
    {
        int TX;
        int TY;
        int MX = rand() % 8;
        int MY = rand() % 8;
        for ( TY = 1, TX = 0; TY <= 19; TX+=2, TY+=2)
        {
            if (MY == BombTracker [TY] && MX == BombTracker [TX])
                {
                  MX = rand() % 8;
                  MY = rand() % 8;
                    TY = -1;
                    TX = -2;
                }
        }
        GameBoard [MX] [MY] = 9;
    if (MY == 0 && MX == 0) //(0,0)
        {
            MX = MX + 1;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //5: my,mx+1
            MY = MY + 1;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //7: my+1,mx+1
            MX = MX - 1;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //6: my+1,mx
        }
    if (MY == 0 && MX == 8) //(8,0)
        {
            MX = MX - 1;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //1: my,mx-1
            MY = MY -1;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //2: my-1,mx-1
            MY = MY + 2;
            MX = MX + 1;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //6: my+1,mx
        }
    if (MY == 8 && MX == 0) //(0,8)
        {
            MY = MY - 1;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //3: my-1,mx
            MX = MX + 1;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //4: my-1,mx+1
            MY = MY + 1;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //5: my,mx+1
        }
    if (MY == 8 && MX == 8) //(8,8)
        {
            MX = MX - 1;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //1: my,mx-1
            MY = MY -1;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //2: my-1,mx-1
            MX = MX + 1;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //3: my-1,mx
        }
    if ((MX >= 1 && MX < 8) && (MY > 7)) //  bottom row
        {
            MX = MX - 1;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //1: my,mx-1
            MY = MY -1;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //2: my-1,mx-1
            MX = MX + 1;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //3: my-1,mx
            MX = MX + 1;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //4: my-1,mx+1
            MY = MY + 1;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //5: my,mx+1
        }
    if ((MX >= 1 && MX < 8) && (MY < 1)) // top row
        {
            MX = MX - 1;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //1: my,mx-1
            MX = MX + 2;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //5: my,mx+1
            MY = MY + 1;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //7: my+1,mx+1
            MX = MX - 1;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //6: my+1,mx
            MX = MX - 1;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //8: my+1,mx-1
        }
    if ((MX > 7) && (MY >= 1 &&MY < 8)) // right collom
        {
            MX = MX - 1;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //1: my,mx-1
            MY = MY -1;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //2: my-1,mx-1
            MX = MX + 1;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //3: my-1,mx
            MY = MY + 2;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //6: my+1,mx
            MX = MX - 1;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //8: my+1,mx-1
        }
    if ((MX > 7) && (MY >= 1 &&MY < 8)) // left collom
        {
            MY = MY - 1;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //3: my-1,mx
            MX = MX + 1;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //4: my-1,mx+1
            MY = MY + 1;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //5: my,mx+1
            MY = MY + 1;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //7: my+1,mx+1
            MX = MX - 1;
            GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //6: my+1,mx
        }
    if ((MX >= 1 && MX < 8)&&(MY >= 1 && MY < 8)) // middle of the board
    {
        MX = MX - 1;
        GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //1: my,mx-1
        MY = MY -1;
        GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //2: my-1,mx-1
        MX = MX + 1;
        GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //3: my-1,mx
        MX = MX + 1;
        GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //4: my-1,mx+1
        MY = MY + 1;
        GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //5: my,mx+1
        MY = MY + 1;
        GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //7: my+1,mx+1
        MX = MX - 1;
        GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //6: my+1,mx
        MX = MX - 1;
        GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //8: my+1,mx-1
    }
    }
        int width = 9;
        int height = 9;
    for (int i = 0; i < height; ++i)
    {
        for (int j = 0; j < width; ++j)
        {
            cout <<GameBoard[i][j] << "  ";
        }
        cout << endl;
        }
        }

