下面的程序要求是输入“50”程序返回“50”,输入“50+4”返回“50” “4”,输入“50*4”返回“50” “50” “50” “50” ,现在程序只可以实现里面的二种情况,第三种情况怎么也实现不出来,有什么别的方法来提取输入的字符串里面的"单数字“ ”+“ ”*“ 后运行不同的程序。里面的乘号分解用了院长的程序,在这里谢谢院长。
 - (defun c:tt()
- (vl-load-com)
- (setq auto_text "50*4")
- (if (not (wcmatch auto_text "*'**"))
- (abc2)
- (if (wcmatch auto_text "*+*")
- (abc2)
- (if (wcmatch auto_text "***")
- (abc1)
- )
- )
- )
- )
- (defun abc1 ( )
- (setq nn (vl-string-search "*" auto_text)
- t1 (substr auto_text 1 nn)
- t2 (substr auto_text (+ nn 2))
- )
- (if (and (distof t1) (setq n (atoi t2)))
- (progn
- (setq t3 "")
- (repeat (1- n)(setq t3 (strcat t3 t1 "+")))
- (setq auto_text (strcat t3 t1))
- )
- )
- (abc2)
- )
- (defun abc2 ( )
- (setq auto_textlen (strlen auto_text))
- (setq text_t "")
- (setq auto_ss nil)
- (while (> auto_textlen 0)
- (setq txet_c (substr auto_text 1 1))
- (if (/= txet_c "+")
- (setq text_t (strcat text_t txet_c))
- (if (/= text_t"")
- (progn
- (setq auto_ss (cons text_t auto_ss))
- (setq text_t ""))))
- (setq auto_text (substr auto_text 2 (- (strlen auto_text) 1)))
- (if (and (< auto_textlen 2) (/= text_t""))
- (progn
- (setq auto_ss (cons text_t auto_ss))
- (setq text_t "")))
- (setq auto_textlen (1- auto_textlen)))
- (setq auto_ss (reverse auto_ss))
- )
|