1.3

练习 1.3:请定义一个过程,它以三个数为参数,返回其中较大的两个数之和。

(define (sum-of-squares-of-largers x y z)
    (cond ((and (<= x y) (<= x z)) (sum-of-squares y z))
        ((and (<= y z) (<= y x)) (sum-of-squares x z))
        ((and (<= z x) (<= z y)) (sum-of-squares x y))
    )
)

(define (sum-of-squares x y)
    (+ (square x) (square y))
)

(define (square x) (* x x))
(sum-of-squares-of-largers 10 30 15)

results matching ""

    No results matching ""