---
// ch03_ex08.javaclass ch03_ex08 {
public static void main( String[] args ) {
while (true) {
int pivot = (int)(Math.random() * 25);
for (int i = 0; i < 25; i++) {
int r = (int)(Math.random() * 25);
if (r < pivot)
System.out.println( r + " < " + pivot );
else if (r > pivot)
System.out.println( r + " > " + pivot );
else
System.out.println( r + " = " + pivot );
}
}
}
}
---
20:35 -- starting 3.8, Lisp version
20:36 -- done
---
;;;; Chapter 3, ex 8
(defun ch03-ex08 ()
(loop
(let ((pivot (random 25)))
(dotimes (i 25)
(let ((r (random 25)))
(cond ((< r pivot) (format t "~a < ~a~%" r pivot))
((> r pivot) (format t "~a > ~a~%" r pivot))
(t (format t "~a = ~a~%" r pivot))))))))
---