锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产成人小视频,日韩欧美成人一区二区,亚洲天堂影视avhttp://www.aygfsteel.com/lzj520/category/38119.htmlzh-cnWed, 18 Nov 2009 23:01:24 GMTWed, 18 Nov 2009 23:01:24 GMT60091118姹傛潹杈変笁瑙掍腑鐨勯」http://www.aygfsteel.com/lzj520/archive/2009/11/18/302812.htmllzj520lzj520Wed, 18 Nov 2009 08:11:00 GMThttp://www.aygfsteel.com/lzj520/archive/2009/11/18/302812.html   int r=0;
  if(l==1|n==1|l==n){
   return 1;
  }else{
  return recursion(l-1,n-1)+recursion(l-1,n);
  }
 }

public static void main(String[] args){
System.out.println(recursion(7,4));
}

lzj520 2009-11-18 16:11 鍙戣〃璇勮
]]>
090310 Exercise 1.11. recursive process and iterativehttp://www.aygfsteel.com/lzj520/archive/2009/03/10/258516.htmllzj520lzj520Tue, 10 Mar 2009 00:51:00 GMThttp://www.aygfsteel.com/lzj520/archive/2009/03/10/258516.htmlhttp://www.aygfsteel.com/lzj520/comments/258516.htmlhttp://www.aygfsteel.com/lzj520/archive/2009/03/10/258516.html#Feedback0http://www.aygfsteel.com/lzj520/comments/commentRss/258516.htmlhttp://www.aygfsteel.com/lzj520/services/trackbacks/258516.htmlExercise 1.11.  A function f is defined by the rule that f(n) = n if n<3 and f(n) = f(n - 1) + 2f(n - 2) + 3f(n - 3) if n> 3. Write a procedure that computes f by means of a recursive process. Write a procedure that computes f by means of an iterative process.

recursive:

(define (fn n)
  (cond ((>= n 3) (+ (+ (fn (- n 1)) (* 2 (fn (- n 2)))) (* 3 (fn (- n 3)))))
        ((< n 3) n)
   ))


 iterative:

(define (re n)
  (if (< n 3)
      n
      (iter 2 1 0 n)
      ))
(define (iter a b c n)
(if(= n 3)
   (ca a b c)
   (iter (ca a b c) a b (- n 1))
   )
)
(define (ca a b c)
  (+ a (* 2 b) (* 3 c) )
)



lzj520 2009-03-10 08:51 鍙戣〃璇勮
]]>
090306 Exercise 1.8 cube-root procedureshttp://www.aygfsteel.com/lzj520/archive/2009/03/06/258241.htmllzj520lzj520Fri, 06 Mar 2009 08:22:00 GMThttp://www.aygfsteel.com/lzj520/archive/2009/03/06/258241.htmlhttp://www.aygfsteel.com/lzj520/comments/258241.htmlhttp://www.aygfsteel.com/lzj520/archive/2009/03/06/258241.html#Feedback0http://www.aygfsteel.com/lzj520/comments/commentRss/258241.htmlhttp://www.aygfsteel.com/lzj520/services/trackbacks/258241.html the cube root of x, then a better approximation is given by the value
(x/y2+2y)/3
Use this formula to implement a cube-root procedure analogous to the square-root procedure. (In
section 1.3.4 we will see how to implement Newton's method in general as an abstraction of these
square-root and cube-root procedures.)

(define (cube x)
  (* x x x))
(define (square x)
  (* x x ))
(define (result x y)
 (/ (+ (/ x (square y)) (* 2 y)) 3))
(define (improve  x guess)
  (result   x guess))
(define (good-enough?  x guess)
  (< (abs (- (* guess guess guess ) x))0.001))
(define (sqrt-iter x  guess)
  (if (good-enough?  x guess)
      guess
      (sqrt-iter x (improve  x guess)
                 )))

lzj520 2009-03-06 16:22 鍙戣〃璇勮
]]>
090306 Exercise 1.6 Square Roots by Newton's Methodhttp://www.aygfsteel.com/lzj520/archive/2009/03/06/258214.htmllzj520lzj520Fri, 06 Mar 2009 07:19:00 GMThttp://www.aygfsteel.com/lzj520/archive/2009/03/06/258214.htmlhttp://www.aygfsteel.com/lzj520/comments/258214.htmlhttp://www.aygfsteel.com/lzj520/archive/2009/03/06/258214.html#Feedback0http://www.aygfsteel.com/lzj520/comments/commentRss/258214.htmlhttp://www.aygfsteel.com/lzj520/services/trackbacks/258214.html can't I just define it as an ordinary procedure in terms of cond?'' she asks. Alyssa's friend Eva Lu
Ator claims this can indeed be done, and she defines a new version of if:
(define (new-if predicate then-clause else-clause)
  (cond (predicate then-clause)
        (else else-clause)))
Eva demonstrates the program for Alyssa:
(new-if (= 2 3) 0 5)
5
(new-if (= 1 1) 0 5)
0
Delighted, Alyssa uses new-if to rewrite the square-root program:
32(define (sqrt-iter guess x)
  (new-if (good-enough? guess x)
          guess
          (sqrt-iter (improve guess x)
                     x)))
What happens when Alyssa attempts to use this to compute square roots? Explain.


(define (new-if predicate then-clause else-clause)
(cond (predicate then-clause)
      (else-clause)))
(define (average x y)
  (/ (+ x y) 2))
(define (improve guess x)
  (average guess (/ x guess)))
(define (good-enough? guess x)
  (< (abs (- (square guess) x))0.001))
(define (square x)
  (* x x))
(define (sqrt-iter guess x)
  (new-if (good-enough? guess x)
          guess
          (sqrt-iter (improve guess x)
                     x)))

sqrt-iter (improve guess x)浣滀負鍙傛暟鏉ヤ紶閫掔粰new-if錛屽湪鎵цnew-if鐨勬椂鍊欙紝灝辨繪槸浼氭墽琛宻qrt-iter (improve guess x)錛岄犳垚浜嗘寰幆銆?br />



lzj520 2009-03-06 15:19 鍙戣〃璇勮
]]>
090305 Exercise 1.3 returns the sum of the squares of the two larger numbershttp://www.aygfsteel.com/lzj520/archive/2009/03/05/258058.htmllzj520lzj520Thu, 05 Mar 2009 11:56:00 GMThttp://www.aygfsteel.com/lzj520/archive/2009/03/05/258058.htmlhttp://www.aygfsteel.com/lzj520/comments/258058.htmlhttp://www.aygfsteel.com/lzj520/archive/2009/03/05/258058.html#Feedback0http://www.aygfsteel.com/lzj520/comments/commentRss/258058.htmlhttp://www.aygfsteel.com/lzj520/services/trackbacks/258058.html
(define (compare x y) (- x y))
(define (sumsquares x y)(+(* x x)(* y y)))
(define (returnlarge a b c)
  (cond ((and (>= (compare a b) 0) (>= (compare c b) 0)) (sumsquares a c))
        ((and (>= (compare a c) 0) (>= (compare b c) 0)) (sumsquares a b))
        ((and (>= (compare c a) 0) (>= (compare b a) 0)) (sumsquares b c))
         )
  )
(returnlarge 3 3 2)

>18

lzj520 2009-03-05 19:56 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 安泽县| 文昌市| 韶关市| 乌拉特中旗| 阜南县| 临泉县| 铁岭县| 亚东县| 桦川县| 田东县| 刚察县| 罗定市| 延长县| 乌什县| 阿坝| 渭源县| 香河县| 于田县| 延川县| 老河口市| 萍乡市| 祁门县| 依兰县| 外汇| 道真| 龙口市| 永年县| 江油市| 缙云县| 博湖县| 泰宁县| 宜兰市| 天长市| 南岸区| 华池县| 无为县| 广丰县| 凤庆县| 临沧市| 遵义市| 施秉县|