单选题:若要表达从1计算到n的运算组合式,(* …(* (* (* (* 1 1) 2) 3) 4) …n)
若要表达从1计算到n的运算组合式,(* …(* (* (* (* 1 1) 2) 3) 4) …n)
定义一个过程。正确的定义为_____。
@[C](2)
A. (define (f product counter max-count)
(f (* counter product) (+ counter 1) max-count ));
B. (define (f product counter max-count)
(cond ((> counter max-count) product)
((<= counter max-count) (f (counter*product) (counter+ 1) max-count )) ));
C. (define (f product counter max-count)
(cond ((> counter max-count) product)
((<= counter max-count) (f (* counter product) (+ counter 1) max-count )) ));
D. (define (f product counter max-count)
(cond ((> counter max-count) product)
((<= counter max-count) (f product counter max-count )) ));
A.(define (f product counter max-count)
(f (* counter product) (+ counter 1) max-count ));
B.(define (f product counter max-count)
(cond ((> counter max-count) product)
((<= counter max-count) (f (counter*product) (counter+ 1) max-count )) ));
C. (define (f product counter max-count)
(cond ((> counter max-count) product)
((<= counter max-count) (f (* counter product) (+ counter 1) max-count )) ));
D. (define (f product counter max-count)
(cond ((> counter max-count) product)
((<= counter max-count) (f product counter max-count )) ));
答案:C
定义一个过程。正确的定义为_____。
@[C](2)
A. (define (f product counter max-count)
(f (* counter product) (+ counter 1) max-count ));
B. (define (f product counter max-count)
(cond ((> counter max-count) product)
((<= counter max-count) (f (counter*product) (counter+ 1) max-count )) ));
C. (define (f product counter max-count)
(cond ((> counter max-count) product)
((<= counter max-count) (f (* counter product) (+ counter 1) max-count )) ));
D. (define (f product counter max-count)
(cond ((> counter max-count) product)
((<= counter max-count) (f product counter max-count )) ));
A.(define (f product counter max-count)
(f (* counter product) (+ counter 1) max-count ));
B.(define (f product counter max-count)
(cond ((> counter max-count) product)
((<= counter max-count) (f (counter*product) (counter+ 1) max-count )) ));
C. (define (f product counter max-count)
(cond ((> counter max-count) product)
((<= counter max-count) (f (* counter product) (+ counter 1) max-count )) ));
D. (define (f product counter max-count)
(cond ((> counter max-count) product)
((<= counter max-count) (f product counter max-count )) ));
答案:C