Question: Data Structures- I was using bubble sort but now I have no idea how to keep the items with their original item # for example,

 Data Structures- I was using bubble sort but now I have

Data Structures- I was using bubble sort but now I have no idea how to keep the items with their original item # for example, when item5 is the smallest it turns into item 1 I don't know how to make it output that it's actually item 5. Help! ****THIS IS IN C++ Please no complicated programs just use at most or something

spend and a number of items and their prices that can be purchased. Write a program to select items with the highest prices that can be purchased with the available money. For each item that is sold, the name and price are given. Note: this strategy does not guarantee that the items selected will have in total the highest possible value (for example, if we have 5$ and if the price of various items is 4,3 and 2$, select only the item of 4$, even though we could buy items of 3 and 2$ ). Input In the first line of the standard input there is the amount of money (real number) available and the number of item types N. Then N pairs of items with their price. N will not exceed 10. Output Print the item names and prices of purchased items (separated by a space) if any. The last line shows the remaining amount of money, if any. You may use arrays or vectors and any sort algorithm you choose

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!