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();
}
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 4 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)