(defun coin (key)
(cond ((= 1 key) 1)
((= 2 key) 5)
((= 3 key) 10)
((= 4 key) 20)
((= 5 key) 50)
(t 0)
))
(defvar stack1 nil)
(setq stack1 nil)
(defun action (account )
(let ((value (pop stack1)))
(if ( or (> (- account (if value
value
0)) 0 )
(= (- account (if value
value
0)) 0 ))
(prog1
(if (> (if value
value
(setq value 0))
0)
(prog1 (print value)
(if (= account 0) (push value stack1))
(if (> account 0)
(action (- account value )))
)
))
(push value stack1)
)))
(defun cc (account kinds-of-coin)
(push (coin kinds-of-coin) stack1)
(cond ((= 0 account) (prog1 1
(pop stack1)
;; (action 20)
))
((or (< account 0) (= kinds-of-coin 0)) (prog1 0
(pop stack1)
))
(t (+ (cc account
(- kinds-of-coin 1))
(cc (- account (coin kinds-of-coin))
kinds-of-coin
)))))
(prog1 (setq stack1 nil)
(setq counter (cc 20 5)))
阅读(997) | 评论(0) | 转发(0) |