精華區beta Cad_Cae 關於我們 聯絡資訊
; file: T0130.LSP (defun f33 (no /) (cond ((<= no 0) 0) ((= no 1) 1) ((= no 2) 1) (T (+ (f33 (- no 2)) (f33 (- no 1)))) ) ) ; end of f33() ; main() begin here ; for no= 2 to 30 do ... (setq no 2) (while (<= no 30) (setq n1 (f33 (1- no))) (setq n2 (f33 no)) (setq x1 (/ (float n2) (float n1))) (princ (strcat "no= " (itoa no) ", x1= " (rtos x1 2 18) "\n") ) (setq no (1+ no)) ) ; end of while() (princ) ; the last line of main() ; end of file 還需要改進的地方 一 模擬 printf("x1= %25.22lf\n", x1); 尚不完整 二 和期望值得比較 期望值= (sqrt(5.0) + 1.0)/(2.0) 三 比較的方法 絕對誤差 和 相對誤差的 user defined function ※ 引述《sjgau (sjgau)》之銘言: : 破 一萬人次紀念 : 可以到 我的 部落格 討論 LISP 學習的問題 : ※ 引述《sjgau (sjgau)》之銘言: : : (princ "hello, world!\n") : : (princ) : : 程式檔案名稱:hello.lsp : : 內容只有以上的兩行。 : : 要執行這個程式,很簡單。 : : 在 AutoCAD 指令行下面,輸入 : : (load "hello") : : 即可正確執行。 : : 更多的內容,請參考我的 BLOG : : http://myblog.pchome.com.tw/sjgau/ : : 參觀次破 1,000 紀念 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 210.243.238.233