---
// ch03_ex07.javaclass ch03_ex07 {
public static void main( String[] args ) {
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:24 -- Starting 3.7, Lisp version
20:28 -- done
---
;;;; Chapter 3, ex 7
(defun ch03-ex07 ()
(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)))))))
---