program deter c c -- fortran program to solve three c -- simultaneous equations by cramer's rule c -- figure 3.3 c integer length, out real a(3,3), det character*1 yesno common /inout/ out c out = 6 10 write(out, 101) call input(a, length) call output(a, length) det = determ(a) write(out, 104) det write(out, 102) read(*, 103) yesno if (yesno .eq. 'y') goto 10 stop 101 format(' determinant of a 3-by-3 matrix') 102 format(' more? ') 103 format(a1) 104 format(' the determinant is', 1pe12.4) end subroutine input(a, n) c -- get values for n and arrays a c integer n, out, i, j real a(3,3) common /inout/ out c n = 3 do 20 i = 1, n write(out, 101) i do 10 j = 1, n write(out, 102) j read(*, 103) a(i,j) 10 continue 20 continue return 101 format(' equation ', i3/) 102 format('+', i4, ': ') 103 format(f10.0) end function determ(x) c c -- find the determinant of the 3-by-3 matrix x c real x(3,3), sum c sum = x(1,1) * (x(2,2)*x(3,3) - x(3,2)*x(2,3)) sum = sum - x(1,2)* (x(2,1)*x(3,3) - x(3,1)*x(2,3)) sum = sum + x(1,3)* (x(2,1)*x(3,2) - x(3,1)*x(2,2)) determ = sum return end subroutine output(a, n) c c -- print out the answers c integer n, out, i, j real a(n,n) common /inout/ out c write(out, 101) ((a(i,j), j = 1, n), i = 1, n) return 101 format(1p3e12.4) end