只需一步,快速开始
焦头烂额,做得晕头转向的,麻烦各位帮我看几道题目,呵呵,帮忙做做~~~感激不尽~~~~
感谢大家的帮忙,麻烦再看看下面一题~~~
3如何在lisp上面表示井字游戏,写一个函数确定这个游戏已经赢了并且是通过哪个符号,如果这个游戏可以有很多种赢法,请全部写出来~
使用道具 举报
这个是第一题,老说没有定义L函数,我水平很差,也有很多题写不出来~~想哭哦!!!
(defun rotate (l n)(if (or (null l) (= n 0)) l (if (< n 0) (append (list (cadr l)) (rotate (append (list (car l)) (cddr l)) (+ n 1))) (append (list (nth n l)) (delete-n (l n))))))
(defun delete-n (l1 n1)(if (and (>= n1 0) (<= n1 (- (length l1)1))) (if (> n1 0) (append (list (car l1)) (delete-n (cdr l1) (- n1 11))) (cdr l1)) nil))
我也写了一个,大家看看,不对的大家指点指点
(defun rotate (l n / L1 L2 L3 N1 YH_KKK) (setq l1 nil l2 nil l3 nil ) (setq n1 (abs n)) (setq l1 l) (repeat n1 (setq l2 (cons (car l1) l2)) (setq l1 (cdr l1)) ) (cond ((> n 0) (progn (setq YH_KKK (car l1) l1 (cdr l1) ) (setq l2 (REVERSE l2)) (setq l2 (cons YH_kkk l2)) (setq l (append l2 l1)) ) ) ((< n 0) (progn (setq l2 (cons (car l1) l2)) (setq l1 (cdr l1)) (setq l2 (REVERSE l2)) (setq YH_KKK (car l2)) (setq l2 (cdr l2)) (setq l1 (cons YH_KKK l1)) (setq l (append l2 l1)) ) ) (T) ) (princ l) (princ))
谢谢楼上的,但是好像有点不和题,呵呵
要求:(ratate '(a b c d e) 2)------(c a b d e) (rotate '(a b c d e) -3)------(b c d a e)
哪里不合题?
我测试没错啊!
你的(ratate '(a b c d e) 2)应该是(rotate '(a b c d e) 2)才对啊
呵呵,对,应该是rotate,但是输入以后显示给rotate赋值太少~~难道我们用的软件不一样?
您需要 登录 才可以下载或查看,没有账号?注册
我用的是clisp,主要是用common lisp编程,可能是有不一样~
第一题我自己的多了个括号,呵呵,去掉就可以了
谢谢~~~
麻烦看看其他两题~~~~~
本版积分规则 发表回复 回帖后跳转到最后一页
小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 ) ©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途
GMT+8, 2024-5-19 02:19 , Processed in 0.191087 second(s), 27 queries , Gzip On.
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.