Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Karel Adds Items Karel needs to swap some items he finds at the bottom of different pits. Karel starts on the east - most tile,

Karel Adds Items
Karel needs to swap some items he finds at the bottom of different pits. Karel starts on the east-most tile, facing west, on the top row of the field. Beneath him are several pits, of various depths (depth is at least one tile). He should go to the bottom of each pit and deposit a number of additional items (i.e., add a number of items to the ones already there). Any column can contain a pit, including the first and last one. He needs to end up at the W end of the top row (our path is always on the top row). He starts with an infinite number of items in his bag.
What we have not told you yet is how Karel knows how many additional items he should depositt at the bottom of each pit. The way he finds out is by calling the function decide items () once he is at the bottom of the pit (where there may be some items or not; this doesn't matter). We have implemented this decide_items () function for you already. You do not have to write it yourself. Instead, you should just call it at the right time (i.e., when you are at the bottom of the pit) and it will work. The function prototype of decide_items () is given below. It does not have a return value, but has an integer pointer as an argument. The effect of calling the function is that the memory location addressed by this pointer now contains the number of additional items that need to be placed.
void decide_items (int ?1** value)
One of the main goals of this exercise is for you to get exposure to pointers. We therefore would encourage you to try your best to get the code working on your own, even if it takes a while. The related chapter in the textbook is a valuable resource here. Once someone just tells you how to use this function, you have missed out on a valuable learning opportunity.
Write your code in add.c.
image text in transcribed

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

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

More Books

Students also viewed these Databases questions