(defun add (lst1 lst2)
(setq k1 (length lst1))
(setq k2 (length lst2))
(if (> k1 k2)
(repeat (- k1 k2) (setq lst2 (cons 0 lst2)) )
(repeat (- k2 k1) (setq lst1 (cons 0 lst1)) )
)
(setq addlst (mapcar '(lambda (x y) (+ x y)) lst1 lst2 ))
addlst
)
(defun lnum (lst n n0)
(setq lst (mapcar '(lambda (x) (* x n)) lst))
(setq zlst (reverse lst))
(repeat n0 (setq zlst (cons 0 zlst) ) )
(reverse zlst)
)
(defun xc(lst1 lst2)
(setq n1 (length lst1))
(setq n2 (length lst2))
(setq j 1 fflst '(0))
(if (> n1 n2)
(while (<= j n2)
(setq fflst (add (lnum lst1 (nth (- j 1) lst2) (- n2 j) ) fflst))
(setq j (+ 1 j))
)
(while (<= j n1)
(setq fflst (add (lnum lst2 (nth (- j 1) lst1) (- n1 j) ) fflst))
(setq j (+ 1 j))
)
)
fflst
)
(defun jinw (blst)
(while (not (apply 'and (mapcar '(lambda (x) (<= x 9)) blst )))
(setq hlst (mapcar '(lambda (x) (rem x 10)) blst))
(setq qlst (mapcar '(lambda (x) (/ x 10)) blst))
(setq qlst (append qlst (list 0)))
(setq blst (add hlst qlst))
)
blst
)
(defun sr(a)
(setq n (strlen a) i 1 lst nil)
(while (<= i n)
(setq lst (cons (atoi (substr a i 1)) lst))
(setq i (+ 1 i))
)
(reverse lst)
)
(defun c:dc()
(setq a (getstring "请输入a="))
(setq b (getstring "请输入b="))
(setq lst1 (sr a))
(setq lst2 (sr b))
(setq tenlst (jinw (xc lst1 lst2)))
(setq str (apply 'strcat (mapcar '(lambda (x) (itoa x)) tenlst ) ) )
(if (= (car tenlst) 0)
(setq str (vl-string-left-trim "0" str))
)
(princ (strcat a "*" b "=" str))
(princ)
)