C
cypisek
I am trying to write a program that will print out all possible
solutions of breaking a 100 bill.
The program will display:
50 20 10 5 1
2 0 0 0 0
as one of the possible solutions.
I already have the logic to print this solution but can't seem to put
that into a loop that will give me all the solutions. I don't know on
how to compare the solution that is already working to the next
solution. Any help would be greatly appreciated:
Here is what I have so far:
resetcounter();
b_50_c = final_sum/b_50;
if (final_sum%b_50==0)
{
writebreakdown(b_50_c,b_20_c,b_10_c,b_5_c,b_1_c,count);
}
else
{
final_sum = final_sum - b_50;
b_20_c = final_sum/b_20;
if (final_sum%b_20==0)
{
writebreakdown(b_50_c,b_20_c,b_10_c,b_5_c,b_1_c,count);
}
else
{
final_sum = final_sum - b_20;
b_10_c = final_sum/b_10;
if (final_sum%b_10==0)
{
writebreakdown(b_50_c,b_20_c,b_10_c,b_5_c,b_1_c,count);
}
else
{
final_sum = final_sum - b_10;
b_5_c = final_sum/b_5;
if (final_sum%b_10==0)
{
writebreakdown(b_50_c,b_20_c,b_10_c,b_5_c,b_1_c,count);
}
else
{
final_sum = final_sum - b_5;
b_1_c = final_sum/b_1;
writebreakdown(b_50_c,b_20_c,b_10_c,b_5_c,b_1_c,count);
}
}
}
}
solutions of breaking a 100 bill.
The program will display:
50 20 10 5 1
2 0 0 0 0
as one of the possible solutions.
I already have the logic to print this solution but can't seem to put
that into a loop that will give me all the solutions. I don't know on
how to compare the solution that is already working to the next
solution. Any help would be greatly appreciated:
Here is what I have so far:
resetcounter();
b_50_c = final_sum/b_50;
if (final_sum%b_50==0)
{
writebreakdown(b_50_c,b_20_c,b_10_c,b_5_c,b_1_c,count);
}
else
{
final_sum = final_sum - b_50;
b_20_c = final_sum/b_20;
if (final_sum%b_20==0)
{
writebreakdown(b_50_c,b_20_c,b_10_c,b_5_c,b_1_c,count);
}
else
{
final_sum = final_sum - b_20;
b_10_c = final_sum/b_10;
if (final_sum%b_10==0)
{
writebreakdown(b_50_c,b_20_c,b_10_c,b_5_c,b_1_c,count);
}
else
{
final_sum = final_sum - b_10;
b_5_c = final_sum/b_5;
if (final_sum%b_10==0)
{
writebreakdown(b_50_c,b_20_c,b_10_c,b_5_c,b_1_c,count);
}
else
{
final_sum = final_sum - b_5;
b_1_c = final_sum/b_1;
writebreakdown(b_50_c,b_20_c,b_10_c,b_5_c,b_1_c,count);
}
}
}
}