本帖最后由 夏生生 于 2024-3-5 16:53 编辑
没蛮看懂题意,按理解写了一下
- (defun c:tt (/ rr lst str key)
- (defun rr (lst Key / Str)
- (setq str (apply 'strcat
- (mapcar '(lambda (x) (strcat x key))
- (reverse (cdr (reverse lst))))))
- (strcat str (last lst) "\n"))
- (setq lst '(("424" "437" "436" "435")
- ("429" "425" "426" "434")
- ("430" "428" "427" "433")
- ("422" "431" "439" "432")))
- (princ "\n")
- (foreach n lst (princ (rr n " ")))
- (princ))
无聊,再补充一个格式化的
- (defun c:tt (/ a i lst p q x)
- (setq lst '(("4204" "437" "436" "435")
- ("429" "421115" "426" "434")
- ("430" "42008" "427" "433")
- ("422" "431" "43639" "4032"))
- a (mapcar '(lambda (x) (apply 'max (mapcar 'strlen x)))
- (apply 'mapcar (cons 'list lst))))
- (princ "\n")
- (foreach n lst
- (setq i 0)
- (foreach m n
- (setq p (strlen m)
- q (nth i a))
- (if (and (= i 0) (= p q))
- (princ m)
- (if (= i 0)
- (progn (repeat (- q p) (princ " ")) (princ m))
- (progn (repeat (1+ (- q p)) (princ " "))
- (princ m))))
- (setq i (1+ i)))
- (princ "\n"))
- (princ))
|