-
Notifications
You must be signed in to change notification settings - Fork 0
/
10813.scm
30 lines (28 loc) · 826 Bytes
/
10813.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
(define ball-vector (make-vector 101 0))
(define n (read))
(define m (read))
(define (vector-init count)
(if (< count 101)
(begin (vector-set! ball-vector count count)
(vector-init (+ count 1)))))
(vector-init 1)
(define (put-iter count)
(define (ball-insert)
(define from (read))
(define to (read))
(define (iter from to)
(define temp (vector-ref ball-vector from))
(vector-set! ball-vector from (vector-ref ball-vector to))
(vector-set! ball-vector to temp))
(iter from to))
(if (< count m)
(begin (ball-insert)
(put-iter (+ 1 count)))
(print-vector 1)))
(define (print-vector count)
(if (<= count n)
(begin (display (vector-ref ball-vector count))
(display " ")
(print-vector (+ count 1)))
(newline)))
(put-iter 0)