I am creating a minesweeper game as a class project.

Qt Code:
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <vector>
  4. #include <fstream>
  5.  
  6. void setupGameBoard();
  7. void calculateSurrounding(int row, int col);
  8. void incrementCellValue(int row, int col);
  9.  
  10. using namespace std;
  11.  
  12. int mines = 0;
  13. int rows = 0;
  14. int columns = 0;
  15. vector<vector<int> > mineField;
  16.  
  17. int main(){
  18.  
  19. cout << "\nLoading game from program..." << endl;
  20. srand (time(NULL));
  21.  
  22. cout << "\nCommon field dimensions include: 9x9:10 mines, "
  23. "16x16:40 mines, 16x30:99 mines." << endl;
  24.  
  25. cout << "Input number of rows: ";
  26. cin >> rows;
  27. cout << "Input number of columns: ";
  28. cin >> columns;
  29. cout << "Input number of mines: ";
  30. cin >> mines;
  31.  
  32. for (int i = 0; i < rows; i++){
  33.  
  34. mineField.push_back(vector<int>(columns, 0));
  35.  
  36. }
  37.  
  38. int num_of_mines = 0;
  39. int minex, miney;
  40.  
  41. while(num_of_mines < mines){
  42.  
  43. minex = rand() % (columns);
  44. miney = rand() % (rows);
  45.  
  46. if(mineField[miney][minex] != 1){
  47.  
  48. mineField[miney][minex] = 1;
  49. num_of_mines++;
  50. }
  51. }
  52.  
  53. setupGameBoard();
  54.  
  55. return 0;
  56. }
  57.  
  58. /*This method sets up the game Board by calculating the number of neighboring mines for each cell.
  59. * calls calculateSurrounding() on each cell
  60. */
  61.  
  62. void setupGameBoard(){
  63.  
  64. int row, col;
  65. row = mineField.size();
  66. col = mineField[0].size();
  67.  
  68. for(int i = 0; i < row; i++){
  69. for(int j = 0; j < col; j++){
  70. if(mineField[i][j] != 1){
  71.  
  72. calculateSurrounding(i,j);
  73.  
  74. }
  75. }
  76. }
  77. }
  78.  
  79. /* Generates numbers for surrounding tiles of mines. The only
  80.  * tiles with numbers are those surrounding mines; these tiles are
  81.  * updated as mines are generated.
  82.  */
  83. void calculateSurrounding(int row, int col){
  84. //should update surrounding tiles to reflect presence of adjacent mine
  85.  
  86.  
  87.  
  88. incrementCellValue(row, col);
  89. }
  90.  
  91. /* increments the cell value(number of mines surrounding it) if the input location is valid
  92. * called from calculateSurrounding() for each adjacent mine.
  93. */
  94. void incrementCellValue(int row, int col){
  95.  
  96. }
To copy to clipboard, switch view to plain text mode 

Here, I need to populate the mine Field with mines randomly (which I have already done), and then set up the game board by calculating the number of neighboring mines for each cell(which is what I'm having trouble doing, I can't figure out how to start). (1 = mine)