- (defun sr (str)
- (setq strlst (mapcar '(lambda (x) (- x 48)) (vl-string->list str)))
- strlst
- )
- (defun ften->bin (lst)
- (setq blst nil binstr nil)
- (while (apply 'or (mapcar '(lambda (x) (/= x 0)) lst ))
- (setq flag 0)
- (setq lst (mapcar '(lambda (x)
- (setq z (/ (+ (* flag 10) x) 2))
- (setq flag (rem (+ (* flag 10) x) 2))
- z
- )
- lst
- )
- )
- (setq blst (cons flag blst))
- )
- (setq binstr (apply 'strcat (mapcar '(lambda (x) (itoa x)) blst)))
- binstr
- )
- (ften->bin (sr (getstring "请输入十进制数n=")))
;能否用于幂计算十进制转二进制 |