write a c++ program that randomly generate a 20 X20 two-dimensional array, board, of type int. An element baord [i][j] is a peak )eaither a max or a min) if all its neighbors (there should be either 3, 5, or 8 neighbors for any cell) are less than board [i][j], or greater than board [i][j]. the program should output all elemts in board, with thier indices, which are peak. it should also output if a peak is a max or a min. use the below code to write the defintion of the functions. #include #include #include #include using namespace std; const int ROWS = 20; const int COLS = 20; void fillBoard(int b[][COLS]); void showBoard(int b[][COLS]); void findPeaks(int b[][COLS]); int main() { int board[ROWS][COLS]; fillBoard(board); showBoard(board); findPeaks(board,ROWS); return 0; } void fillBoard(int b[][COLS]) { srand(time(0)); for (int i =0; i < ROWS; i++) for (int j = 0; j < COLS; j++) b[i][j] = rand(); }
write a c++ program that randomly generate a 20 X20 two-dimensional array, board, of type int. An element baord [i][j] is a peak )eaither a max or a min) if all its neighbors (there should be either 3, 5, or 8 neighbors for any cell) are less than board [i][j], or greater than board [i][j]. the program should output all elemts in board, with thier indices, which are peak. it should also output if a peak is a max or a min. use the below code to write the defintion of the functions.
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <iomanip>
using namespace std;
const int ROWS = 20;
const int COLS = 20;
void fillBoard(int b[][COLS]);
void showBoard(int b[][COLS]);
void findPeaks(int b[][COLS]);
int main()
{
int board[ROWS][COLS];
fillBoard(board);
showBoard(board);
findPeaks(board,ROWS);
return 0;
}
void fillBoard(int b[][COLS])
{
srand(time(0));
for (int i =0; i < ROWS; i++)
for (int j = 0; j < COLS; j++)
b[i][j] = rand();
}

Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 4 images









