program bsort2 c c -- test sort routine c -- function ran needed c -- figure 6.4 c integer length, out, max, i real x(500) common /inout/ out, max c out = 6 max = 500 10 call input(x, length) write(out, 105) (x(i), i = 1, length) c -- random list call output(x, length) write(out, 102) c -- sorted list call output(x, length) write(out, 103) do 20 i = 1, length x(i) = length + 1 - i 20 continue c -- reversed list call output(x, length) write(out, 104) goto 10 101 format(1x, a1) 102 format(' random') 103 format(' sorted') 104 format(' reversed') 105 format(1x, 10f7.2) end subroutine input(x, n) c c -- get n and generate random vector x c integer n, out, i, max real x(1) common /inout/ out, max c 5 write(out, 101) read(*,102) n if (n .gt. max) goto 5 if (n .lt. 0) goto 99 do 10 i = 1, n x(i) = rand(0) * 100.0 10 continue return 99 stop 101 format(' how many points? ' ) 102 format(i3) end subroutine output(x, n) c c -- print the vector x c integer n, out, i, beep real x(1) common /inout/ out, max data beep/7/ c write(out, 101) beep call sort(x, n) write(out, 101) beep write(out, 102) (x(i), i = 1, n) return 101 format(1x, a1) 102 format(1x, 10f7.2) end