Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
6
Task/Count-the-coins/JavaScript/count-the-coins-5.js
Normal file
6
Task/Count-the-coins/JavaScript/count-the-coins-5.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
var amount=100, coin=[1,5,10,25]
|
||||
var t=[1]; for (t[amount]=0, a=1; a<amount; a++) t[a]=0 // initialise t[0..amount]=[1,0,...,0]
|
||||
for (var i=0, e=coin.length; i<e; i++)
|
||||
for (var ci=coin[i], a=ci; a<=amount; a++)
|
||||
t[a] += t[a-ci]
|
||||
document.write( t[amount] )
|
||||
Loading…
Add table
Add a link
Reference in a new issue