Chinaunix首页 | 论坛 | 博客
  • 博客访问: 183261
  • 博文数量: 43
  • 博客积分: 1150
  • 博客等级: 少尉
  • 技术积分: 450
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-29 15:52
文章分类

全部博文(43)

文章存档

2012年(18)

2011年(24)

2008年(1)

分类: LINUX

2011-09-07 10:09:31

(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)))
阅读(987) | 评论(0) | 转发(0) |
0

上一篇:Common Lisp书籍

下一篇:emacs插件pc lint 1.0

给主人留下些什么吧!~~