- (defun stair-level-steps (step-num / stair-level remainder stair-level-steps new-remainder j stair-level-list stair-level-steps new-stair-level-list temp)
- (setq stair-level (fix (/ step-num 18)) ;; 计算 step-num 除以 18 的商,存储在 b
- remainder (rem step-num 18 ) ;; 计算 n 减去 n 除以 18 的商乘以 18 的结果,存储在 remainder
- stair-level-steps nil ;; 创建一个空列表 result-list
- )
- (if (zerop remainder)
- (repeat (fix stair-level)
- (setq result-list (append result-list (list 18)))
- )
- (progn
- (setq stair-level-steps (fix (/ step-num (+ stair-level 1)))
- new-remainder (fix (- step-num (* (+ stair-level 1) stair-level-steps)))
- j 0
- stair-level-list nil
- new-stair-level-list nil
- temp nil
-
- )
- (repeat (fix (+ 1 stair-level))
- (setq stair-level-list (append stair-level-list (list stair-level-steps)))
- )
- (while (> new-remainder 0)
- (repeat new-remainder
- (setq temp (nth j stair-level-list)
- temp (+ 1 temp)
- new-stair-level-list (append new-stair-level-list (list temp))
- j (1+ j)
- )
- )
- (reverse new-stair-level-list)
- )
-
- )
- )
- )
- (defun c:tt()
- (stair-level-steps (getreal "\n 请输入级数"))
- )
各路大神,请问这段代码有什么问题,为啥输入的结果是nil
|