Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started