1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Olegator [25]
4 years ago
9

Implement the make change algorithm you designed in the previous problem. Your program should read a text file "data.txt" where

each line in "data.txt" contains three values c, k and n. Please make sure you take your input in the specified order c, k and n. For example, a line in "data.txt" may look like the following:3 4 38
where c = 3,k = 4,n = 38. That is, the set of denominations is {30,31,32,33,34} = {1,3,9,27,81}, and we would like to make change for n = 38. The file "data.txt" may include multiple lines like above.

The output will be written to a file called "change.txt", where the output corresponding to each input line contains a few lines. Each line has two numbers, where the first number denotes a de- nomination and the second number represents the cardinality of that denomination in the solution. For example, for the above input line ‘3 4 38’, the optimal solution is the multiset {27, 9, 1, 1}, and the output in the file "change.txt" is as follows:

27 1 91 12

which means the solution contains 1 coin of denomination 27, one coin of 9 and two coins of denomination
Computers and Technology
1 answer:
Tanya [424]4 years ago
4 0

Answer:

Answer explained below

Explanation:

Below is the code for Greedy change algorithm in C++. Please let me know what  does c ,k and represent in the question. so that i can update according to requirement

#include <bits/stdc++.h>  

using namespace std;  

int deno[] = { 1, 3,9,27,81 };  

int n = sizeof(deno) / sizeof(deno[0]);  

void findMin(int V)  

{  

   // Initialize result  

   vector<int> ans;  

   // Traverse through all denomination  

   for (int i = n - 1; i >= 0; i--) {  

       // Find denominations  

       while (V >= deno[i]) {  

           V -= deno[i];  

           ans.push_back(deno[i]);  

       }  

   }  

   // Print result  

   for (int i = 0; i < ans.size(); i++)  

       cout << ans[i] << " ";  

}  

int main()  

{  

   int n = 38;  

   cout << "Following is minimal number of change for " << n << ": ";  

   findMin(n);  

   return 0;  

}

You might be interested in
((Excel)) please help, 100 points, and brain crown thingy, not only that, i will make several of these so you can get several hu
cupoosta [38]

Answer:

First you read the question and numbers, then you use the numbers in the correct way and you try reallllyyy hard, you will find your answer! Hope this helps! :D

4 0
3 years ago
Which element of the word program window contains buttons for saving a document and for undoing, redoing, and repeating a change
miskamm [114]
The answer is the Quick Access Toolbar. However, it is not only for saving files or undoing your work. Containing a set of commands that are independent, this toolbar is actually customizable wherein you could change these icons to the ones you really need and frequently use. By tweaking the settings, you can even add commands to the Quick Access Toolbar that are not in the ribbon (like New, Open and Print).
7 0
4 years ago
___ apps can allow you to lock your mobile device and sim card remotely.
alex41 [277]
Mobile Security <span>apps can allow you to lock your mobile device and sim card remotely. </span>
6 0
3 years ago
Which concept often comes in conflict with privacy rights?
likoan [24]
The correct answer is C.
8 0
3 years ago
Write a function called middle(string str) that returns a string containing the middle character in str if the length of str is
jenyasd209 [6]

Answer:

Note: a) If the length of the string is odd there will be two middle characters.

Explanation:

b) If the length of the string is even there will be one middle character. There was a problem connecting to the server. Please check your connection and try running the trinket again.

3 0
2 years ago
Other questions:
  • Which option will Joan use to get a glimpse of how her presentation will look when she presents it to her audience? Joan will us
    12·1 answer
  • List any four routes of transmission of computer virus. <br>please give me answer​
    8·1 answer
  • Which of the following is something you need to keep an eye out for
    7·2 answers
  • What is nominal data?
    5·1 answer
  • Why is investing in a mutual fund less risky than investing in a particular company's stock? A. Mutual funds only invest in blue
    14·2 answers
  • You
    15·2 answers
  • The signal(s)that control the direction that data is transferred on its buslines is the _________ signal(s).
    11·1 answer
  • what are the main technologies that have contributed to the growth and commercialization of the internet .​
    5·1 answer
  • What is the way to discover requirments for software projects ?
    14·1 answer
  • Hello, I am smart without showing off and I will help you with your homework and tell you the correct answers (◠ᴥ◕ʋ).​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!