Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please use VSCode c++ to help me solve this problem.the sample_config.txt will look like this:12x220,124,105,106,106,96,84,144,155,156,157,158,159,159,149,139,129,119,109,99,89,79,6 This program will drop marbles into a box as long

please use VSCode c++ to help me solve this problem.the sample_config.txt will look like this:12x220,124,105,106,106,96,84,144,155,156,157,158,159,159,149,139,129,119,109,99,89,79,6

image text in transcribed
This program will drop marbles into a box as long as it is possible to do so and calculate the total number marbles in the box. In addition, the program will output a text file box.txt displaying the box with all the marbles inside. Each box has different configuration, which can be changed through a config.txt file. 111111111122 0123456789012345678901 0 # # # # # ## ##### +######### # . . . .# .# @ . . . @ . . . . .# . . . . . .@. . .@. . . . . .# . . @@@ . . .@. . . . . .# . . # 9 # . 10 #. . 11 ####### ###HHHHHH###### The config.txt contains the following information: - The first line indicates the size of the box - The second line indicates the opening of the box (a.k.a. the '+' sign in the figure above) The rest of the information indicates the configuration inside the box. (a.k.a the '@' sign in the figure above) -The ! indicates blank space. - The '#' indicates the side of the box. - The sample config.txt is included for your reference. How a marble falls into the box: -The marble only falls through the opening of the box. - The marble always falls straight down until it hits something. -If it hits '@' or another marble, the marble will fall to the left spot if the left spot is available. If not, it will fall to the right. - The marble will come to rest if there is no possible move (left or right). Sample run for the first three marbles: 11111 1111122 0123456789012345678901 # # # # # # # # # # ## +# ##### # # # # . . .# . . . . .# . . . . . . . . . . . . . . .# . . .@. . . @ . . . . .# . . . .@ . . . @ . . . . . .# . . .@ . . . . . . . . .@. . . . . .# # , . . . . . . . . . 000@ . . . . . . # 9 # . . . .# 10 # . . . 11 ###### #### # #### After a while (with 24 marbles in the box) it becomes: 11111 11 11122 0123456789012345678901 0 # # # # # # # #####+######### # . . . . . .# . . . 000 . . . . . . .# . @ooo@@ . . . . .# . . . . . @ooo@ . . . . . .# . . @@@ooo@ . . . . . .# . . . .0000@ . . . . . .# 00 # . . . 0. 00000@. . . . # 9 #. . . . . ..@ @ @ @ @@@. .# 10 # . . . . . . . . . .# 11 # # # # # # # # # # # # # ######### The final box with 89 marbles: 111111111122 0123456789012345678901 0 # # # # # # # # # # ##+ # # ####### # . . . . . . . . . 000. . . . . . .# UN - #. . . . . . 00000 . . . . . .# . . . 0000000 . . . . .# . oo@ooo@@o. . . .# . . 000@ooo@ooo. . .# . . Do@@@ooo@oooo . . # # . . . . 0000 . OOOO@oooo0 . # 00 9 @@oooooo# 10 #. 00000 . . . . . . .0000000# 11 # # # # # # # # # # # # # ######1##

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions

Question

How can poor nutrition lead to anemia?

Answered: 1 week ago