Browsing all articles tagged with SICP
[SICP]分硬币问题
(define (count-change amount)
(cc amount 5))
(define (cc amount kinds-of-coin)
(cond ((= amount 0) 1)
((or (< amount 0) (= kinds-of-coin 0)) 0 )
(else (+ (cc amount (- kinds-of-coin 1))
(cc (- amount (first-denomination kinds-of-coin)) kinds-of-coin))
)
)
)
(define (first-denomination kinds-of-coin)
(cond ((= kinds-of-coin 1) 1)
((= kinds-of-coin 2) 5)
((= kinds-of-coin 3) 10)
((= kinds-of-coin 4) 25)
((= kinds-of-coin 5) 50)
)
)
(count-change 100)
页面
Categories
- 92383 (1)
- lonely planet (25)
- Uncategorized (1)
- 一些故事 (3)
- 利其器 (10)
- 善其事 (62)
- 小说翻译 (2)
- 负暄琐话 (74)
need follow
RSS
Blogroll
云
Android
apple
BlackBerry
Blake Ross
craigslist
del.icio.us
elisp
emacs
firefox
flickr
Founders At Work
Google
infoq
ios
iphone
lonely planet
notes
orgmode
pil-handbook
python
RIM
Yahoo
书
兵马俑
创业
华山
单向街
四川
国际米兰
图像
宝鸡
工作
成都
旅游
旅行
杭州
江南
百度
翻译
西安
跑步
陕西
马拉多纳
黄山
黑莓
laihj


