Find minimum number of coins that make a given value: Difference between revisions

Find minimum number of coins that make a given value en FreeBASIC
(Added solution for Action!)
(Find minimum number of coins that make a given value en FreeBASIC)
Line 278:
}
</pre>
 
 
=={{header|FreeBASIC}}==
<lang freebasic>#define floor(x) ((x*2.0-0.5) Shr 1)
 
Dim As Integer amount = 988
Dim As Integer sumCoins = 0
Dim As Integer n, tmp
Dim As Integer coins(8) = {1, 2, 5, 10, 20, 50, 100, 200}
 
Print "Make a value of"; amount; " using the coins 1, 2, 5, 10, 20, 50, 100 and 200:"
 
For n As Integer = Ubound(coins) To 0 Step -1
tmp = floor(amount/coins(n))
If tmp >= 0 Then
Print tmp; " *"; coins(n)
sumCoins += tmp
amount Mod= coins(n)
End If
Next n
Sleep</lang>
{{out}}
<pre>Make a value of 988 using the coins 1, 2, 5, 10, 20, 50, 100 and 200:
4 * 200
1 * 100
1 * 50
1 * 20
1 * 10
1 * 5
1 * 2
1 * 1</pre>
 
 
=={{header|Go}}==
2,169

edits