Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #reader(lib "htdp-advanced-reader.ss" "lang")((modname Bai4) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #t #t none #f ())))
- (display "Nhap so K: ")
- (define K (read) )
- (newline)
- (display "Nhap so N: ")
- (define N (read) )
- (newline)
- (define (Contain l n)
- (cond
- ((null? l) #F )
- ((= n (car l)) #T)
- (else (Contain (cdr l) n))
- )
- )
- (define (NumToList n l)
- (cond
- ((zero? n) l)
- ((Contain l (remainder n 10)) (NumToList (quotient n 10) l))
- (else (NumToList (quotient n 10) (cons (remainder n 10) l)))
- )
- )
- (define (Remove n l)
- (cond
- ((null? l) l)
- ((= n (car l)) (Remove n (cdr l)))
- (else (cons (car l) (Remove n (cdr l))))
- )
- )
- (define (Concordant num l count)
- (if (zero? count)
- (begin
- (display num)
- (newline)
- )
- (for-each
- (lambda (a)(Concordant (+ a (* 10 num)) (Remove a l) (- count 1)))
- l
- )
- )
- )
- (define l (NumToList N '()))
- (display l)
- (newline)
- (Concordant 0 l K)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement