logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

Given a list of commands determine at particular points what animal is contained in a requested cage.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Organization

Objective

Give practice with dynamic memory in C.

Story

You managed to round up all the animals. Now you need to structure your park. You and your employees need to be able to look up information quickly, so you will write a program to help assist you and your “assistant to the park managers”. Again the park is composed of multiple sections, and each section will have multiple cages. You plan on doing the following,

Changing the number of cages within particular park sections

Adding and removing animals to different cages within particular sections

Listing the animal within a particular cage of a particular park section

 

Problem

Given a list of commands determine at particular points what animal is contained in a requested cage.

 

Input

Input will begin with a line containing 1 integer, N (1 ≤ N ≤ 100,000), representing the number of park sections. Each park section initially contains 0 cages.

Following this line will be list of commands. The commands must be processed in the order they are given. Each command begins with a number and can be 1 of 4 types. The types are listed below

1 S C

This command changes the number of cages in some particular section. The section that is modified is the section numbered S (1-indexed). The resulting number of cages in section S is the number C. This could increase or decrease the number of cages. Any animal that was in a cage with ID after C (1-indexed) is sent back to the warehouse. If the section number is invalid, no changes should be made.

2 S C A

This command adds an animal to a cage. The section that is modified is the section numbered S (1-indexed). The resulting cage the animal is added to is C (1-indexed), if the cage is empty and the section and cage exists. If an animal is already present in cage C of section S or there is no section S or cage C of section S does not exist, then the animal is NOT added to the cage. The type of animal is A (a string of at most 1000 alphanumeric characters).

3 S C

This command requests the animal type of the animal in cage C (1-indexed) of section S. If no animal is present or the section or cage number is invalid, the phrase “No animal found.” (quotes for clarity) should be printed instead.

4

This command requests that the program ends (I guess we finished organizing all the exhibits).

 

(5/5)
Attachments:

Expert's Answer

289 Times Downloaded

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

289 Times Downloaded

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Atharva PatilComputer science

552 Answers

Hire Me
expert
Chrisantus MakokhaComputer science

640 Answers

Hire Me
expert
AyooluwaEducation

687 Answers

Hire Me
expert
RIZWANAMathematics

861 Answers

Hire Me

Get Free Quote!

350 Experts Online