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;="">for (int j = 0; j < cols;="">b[i][j] = rand();}
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;="">for (int j = 0; j < cols;="">b[i][j] = rand();}
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here