0

Not Yet Answered # Coin Change Problem

You have to write a program which takes 30 integers representing collection of coins. Each integer represents worth of each coin. The program should also take another input “amount” whose change needs to be found. Your program should be finding the change using minimum number of coins. If change is not possible then it should display an appropriate message. Output of the program should be list of all coins used to find the change using minimum number of coins. Any number could be input from 0 to infinite...This is only for beginners!

jonsca 1,059 Discussion Starter kenny21 peter_budo 2,516 Need some help with this Array. I am trying to get the sum of the even numbers and the sum of the odd numbers using a for each loop. I know the answers to what I am trying to achive are sum of even = 84 and the sum of ...

0

0

What have you tried so far? Have you tried out an example with paper and pencil to get the thought process (which makes it much easier to code)?

Also please see this:

http://www.daniweb.com/forums/announcement8-2.html

0

What have you tried so far? Have you tried out an example with paper and pencil to get the thought process (which makes it much easier to code)?

Also please see this:

http://www.daniweb.com/forums/announcement8-2.html

i did this and now its working!

```
# include <iostream>
using namespace std;
void main()
{
int x[10],a=0,amount=0,b,temp,c=0,d=0;
cout<<"Enter your coins:"<<endl;
for (a=0;a<=9;a++) //enter array
cin>> x[a];
//sorting array so that amount could be compared later on
for (b=0;b<=9;b++)
{
for(a=b+1;a<=9;a++)
{
if (x[a]>x[b])
{
temp=x[a];
x[a]=x[b];
x[b]=temp;
}
}
}
//entering amount
cout<<"Enter Amount:"<<endl;
cin>>amount; //getting the desired number
cout<<endl<<"Your Change: "<<endl;
c=amount;
//comparing each number with amount
for (a=0;a<=9;a++)
{
if ((x[a]==amount))
{
cout<<amount<<"...";
amount=amount-x[a];
d=x[a]+d;
}
}
amount++;
for (a=0;a<=9;a++)
{
if((x[a]!=amount)&&(x[a]<amount))
{
cout<<x[a]<<"...";
amount=amount-x[a];
d=x[a]+d;
}
}
//this is used as the default statement if the entered amount is inappropriate
if (d!=c)
cout<<endl<<"Please enter your desired amount again as you do not have sufficient coins to get that change...";
cout<<endl;
}
```

*Edited 6 Years Ago by WaltP*: Added CODE Tags

0

As you did disabled communication emails from forum and do not wish to received any PM from other members you leave me no choice then reply publicly.

This thread cannot be removed from the forum because: Acceptable Use Policy - Legal Obligations

DaniWeb LLC reserves full rights and privileges to information posted to anywhere within the daniweb.com domain by its members and staff.

Also when ever you post your assignment on technical forums and need help to solve issue you are cheating on your teacher, and also you are publishing what ever you done. I'm sorry we will not remove it and if you have problem with your classmates possibly copying your work you should mention to your teacher that you posted part of your work on a forum.

Therefore any further request for removal of above posts will be ignored.

This article has been dead for over six months. Start a new discussion instead.

Recommended Articles

When I execute this progammatically, I get a table with row heights much larger than when I do this manually.

Note : Sel is the Word.Selection object and the Clipboard contains an Excel Table.

```
public void AddClipboard()
{
Sel.PasteExcelTable(false,false, false);
var t = Sel.Tables[Sel.Tables.Count];
t.AutoFitBehavior(Word.WdAutoFitBehavior.wdAutoFitContent);
}
```

the function that I created to find the ...