- (defun c:tt( / randomnum i num Random)
- (defun Random (x y / RandomObj rtn)
- (setq RandomObj (vlax-create-object "System.Random"))
- (setq rtn (fix (+ x (* (vlax-invoke RandomObj 'nextdouble) (- y x)))))
- (vlax-release-object RandomObj)
- rtn
- )
- (setq randomnum (Random 0 100))
- (setq i 0)
- (princ "\n猜数字游戏开始0-99!")
- (while
- (setq i (1+ i))
- (setq num (getint "\n猜数字游戏,请输入你的答案:"))
- (if (= num randomnum)
- (progn
- (princ (strcat "\n太厉害了,你只猜了" (itoa i) "次就猜对了!"))
- (setq randomnum (Random 0 100))
- (setq i 0)
- (princ "\n猜数字游戏开始0-99!")
- )
- (progn
- (if (> num randomnum)
- (princ "\n太大了!")
- (princ "\n太小了!")
- )
- )
- )
- )
- )
|