Answered step by step
Verified Expert Solution
Link Copied!

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,

image text in transcribed

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

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

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

More Books

Students also viewed these Databases questions

Question

Explain the causes of indiscipline.

Answered: 1 week ago