如何找到数字中的最大数字?球拍

时间:2015-11-04 23:26:42

标签: racket

(define hmaxDigit 
  (lambda (n b)
    (cond
      ((< n 10) n)
      ((> n (* 10 b)) (hmaxDigit n (* b 10)))
      ((< 10 (remainder b))
       ((> (quotient n b) (remainder n b)) (quotient n b))
       ((< (quotient n b) (remainder n b)) (remainder n b)))))

这就是我所拥有的,但它仅适用于2位数字。

1 个答案:

答案 0 :(得分:1)

PartsController

需要填写If n<10 then n is the_maximum_digit else the_maximum_digit is the maximum of the first_digit and the maximum of the remaining digits. (define (maximum-digit n) (cond [(< n 10) n] [else (max (first-digit n) (maximum-digit (remaining-digits n)))])) first-digit等详细信息。