Question: C Program/ c language Shipping You finally achieved your dream of managing Omazan's large convoy of ships; it's so futuristic it's next gen shipping. These

C Program/ c language  C Program/ c language Shipping You finally achieved your dream of
managing Omazan's large convoy of ships; it's so futuristic it's next gen
shipping. These ships carry good across the globe. Ships will send in
requests to join and leave your convoy, and traders will query the
contents of the convoy (either the goods on ships and potentially the
ids of said ships). Your job is to write program which stores

Shipping You finally achieved your dream of managing Omazan's large convoy of ships; it's so futuristic it's next gen shipping. These ships carry good across the globe. Ships will send in requests to join and leave your convoy, and traders will query the contents of the convoy (either the goods on ships and potentially the ids of said ships). Your job is to write program which stores all this information and services the traders' strange inquiries. As an example you could have the following set of ships, Ship 3 Contents Cocoa, Sugar, Sugar, Grain Ship ID 4 Ship ID 5 Ship 4 Contents Corn, Carrot Ship ID 3 Ship 5 Contents Car, Car, Car, Car, Car, Car Ship 3 being the first ship in the convoy. To prevent nautical accidents from happening, you only allow ships to leave when they are the last ship in the convoy. If ship 3 requests to leave (note it's not the last ship in the convoy), it won't be able to immediately. For this reason when Ship 3 requests to leave it will swap positions with ship 4, and then depart from the convoy A trader does not know the ids of the ships, so they might request the id of a ship at a location in the convoy. Alternatively, a trader may request the name of an item in some particular container of a specified ship (by location starting index at 1). Suppose we have the original convoy of ships 3, 5, and 4. Imagine a trader asks what the 1 ship's 4 good is. The 1 ship has Ship ID 3. The 4th good is Grain. For this reason Grain would be reported to the trader. Ifa trader asks for a ship or container not in the convoy, you should report that the ship-container request is not valid. Input Specification Each line of input describes either an event or contains the integer -1 If a ship wishes to leave, the event begins with the integer 0 (zero). Following the integer 0, the id of the ship (1 indexed) will be given. The id given will be a valid ship in the convoy. If a ship wishes to join the convoy, the event begins with the integer 1 (one). Following the integer 1, a positive integer, , representing the number of containers on the ship will be given. Following be (n 10,000) space separated container descriptions. Each container description will be composed of two values a positive integer k (k100) representing the number of alphanumeric characters in the containers name and a string composed of only k

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!