#include winclude #include using namespace std; // TODo: fill in the code to create a new board // The board is an array of arrays, create the container array // Then add arrays for a diagonal with 1 more than the row index // Initialize ALi elements to e to avoid corrupting the count int** createNewBoard(int rows) I/ ToDo: delete the arrays that make up the board // The board is an array of arrays, delete the arrays void freeboard(int *board[], int rows) // runsimulation does the logic to run the Galton board // to see how the balls drop through_the pegs. // @param: board is a two-dimensional diagonal array. // @param: nTests is the number of tests to run. void runsimulations(int *board[], int rows, int nTests) int i, j; // Loop to run the number of tests for (int trials - ®; trials < nTests; trials++) !/ Dropping a ball in always hits the first peg. i-j- e; board[i][]]++; simulate the ball dropping. // It either falls straight down or bounces to the right. // But gravity always takes it down to the bottom for (i - 1; i < rows; i++) int right = rand()%2; if (right -- 1) j++; board[i][j]++; // ToDo: display the board values as a nice triangle chart. // use setw(4) to separate values in a row. // eparam: board is a two-dimensional diagonal array void display(int *board[], int rows) int main() int boardsize, numTests, seed; cout « "Enter the size of the board: "; cin » boardsize ; cout « "Enter the number of tests: "; cin >» numTests; cout « "Enter the random seed: "; cin » seed; srand(seed); I/ create the Galton Board, run simulation, display results and free int "board - createNewBoard(boardsize); runsimulations(board, boardsize, numTests); display(board, boardsize); freeboard(board, boardsize); return e;
#include winclude #include using namespace std; // TODo: fill in the code to create a new board // The board is an array of arrays, create the container array // Then add arrays for a diagonal with 1 more than the row index // Initialize ALi elements to e to avoid corrupting the count int** createNewBoard(int rows) I/ ToDo: delete the arrays that make up the board // The board is an array of arrays, delete the arrays void freeboard(int *board[], int rows) // runsimulation does the logic to run the Galton board // to see how the balls drop through_the pegs. // @param: board is a two-dimensional diagonal array. // @param: nTests is the number of tests to run. void runsimulations(int *board[], int rows, int nTests) int i, j; // Loop to run the number of tests for (int trials - ®; trials < nTests; trials++) !/ Dropping a ball in always hits the first peg. i-j- e; board[i][]]++; simulate the ball dropping. // It either falls straight down or bounces to the right. // But gravity always takes it down to the bottom for (i - 1; i < rows; i++) int right = rand()%2; if (right -- 1) j++; board[i][j]++; // ToDo: display the board values as a nice triangle chart. // use setw(4) to separate values in a row. // eparam: board is a two-dimensional diagonal array void display(int *board[], int rows) int main() int boardsize, numTests, seed; cout « "Enter the size of the board: "; cin » boardsize ; cout « "Enter the number of tests: "; cin >» numTests; cout « "Enter the random seed: "; cin » seed; srand(seed); I/ create the Galton Board, run simulation, display results and free int "board - createNewBoard(boardsize); runsimulations(board, boardsize, numTests); display(board, boardsize); freeboard(board, boardsize); return e;
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Please complete the code, in C++ to pass the tests, the first image is the assignment, the second screenshot provides the starter code. The Test case will be:
Sample Test Case:
Enter the size of the board: 7
Enter the number of tests: 500
Enter the random seed: 17
500
248 252
135 239 126
72 188 182 58
36 132 177 124 31
19 71 180 139 71 20
7 45 130 155 105 46 12
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education