c    14.$B%d%3%SK!$K$h$k2rK!(B
c      $B?9@n(B $BLwBg(B , 22980138
c
      program ex14
c
      implicit none
      integer :: j,n
      real :: a(3,4),b(3,4),c(3,4)
c
      data (a(1,j),j=1,4)/ 50.0e0,  2.0e0,  1.0e0, 5.7e1/
      data (a(2,j),j=1,4)/  1.0e0, 40.0e0,  2.0e0, 8.7e1/
      data (a(3,j),j=1,4)/  2.0e0,  1.0e0, 20.0e0, 6.4e1/

      data (b(1,j),j=1,4)/ 80.0e0 , 2.0e0, -5.0e0, 7.59e1/
      data (b(2,j),j=1,4)/  1.0e0,-40.0e0,  1.0e0,-8.36e1/
      data (b(3,j),j=1,4)/  5.0e0,  1.0e0, 50.0e0, 1.727e2/

      data (c(1,j),j=1,4)/ 50.0e0,  2.0e0,  1.0e0, 6.94e1/
      data (c(2,j),j=1,4)/ -1.0e0, 20.0e0, -2.0e0, 4.591e1/
      data (c(3,j),j=1,4)/  5.0e0,  1.0e0, 10.0e0, 2.699e1/

      write(6,*)'14.$B%d%3%SK!$K$h$k2rK!(B'
      write(6,*)''
      write(6,*) '(1)'
      n=3
      call yakobi14(a,n)

      write(6,*)''
      write(6,*) '(2)'
      n=3
      call yakobi14(b,n)

      write(6,*)''
      write(6,*) '(3)'
      n=3
      call yakobi14(c,n)

      stop
  100 format(1x,i2,1x,a3,1x,f7.4,1x,f7.4,1x,f7.4) 
      end

c-----$B%d%3%SK!$N%5%V%k!<%A%s(B
      subroutine yakobi14(a,n)
      implicit none
      integer :: i,j,k,n,m,l
      real :: xk(n),xk1(n),ek,ek1
      real :: a(n,n+1),aa(n,n),bb(n)
      
      do i=1,n
       do j=1,n
        aa(i,j)=a(i,j)
        bb(i)=a(i,n+1)
       enddo
      enddo
      write(6,*)''
      do m=1,n
        if (n==2) then
        write(6,200) m,'   ',(aa(m,l),l=1,n),'   ',bb(m)
        elseif (n==3) then
        write(6,300) m,'   ',(aa(m,l),l=1,n),'   ',bb(m)
        endif
      enddo
      do j=1,n
         xk(j)=0.0e0
      enddo
      write(6,*)''
      write(6,*)'$B=i4|CM(B'
      write(6,'(a3,f10.5)')'x=',xk(1)
      write(6,'(a3,f10.5)')'y=',xk(2)
      if (n==3) then
      write(6,'(a3,f10.5)')'z=',xk(3)
      endif

      i=0
      ek =1.0e3
      ek1=1.0e3
      do while (ek1 > 1.0e-3)
         i=i+1
         do j=1,n
            xk1(j)=bb(j)/aa(j,j)
            do k=1,n
               if (k/=j) then
                  xk1(j)=xk1(j)-((aa(j,k)*xk(k))/a(j,j))
               endif
            enddo
         enddo
         write(6,*)''
         write(6,400) i
         write(6,'(a3,f10.5)')'x=',xk1(1)
         write(6,'(a3,f10.5)')'y=',xk1(2)
         if (n==3) then
            write(6,'(a3,f10.5)')'z=',xk1(3)
         endif

c         write(6,*)ek
         ek1=0.0e0
         do j=1,n
            ek1=ek1+abs(xk1(j)-xk(j))
         enddo
         write(6,*)'$B<}B+EY(B',ek1
         if (ek1>ek) go to 10

         do j=1,n
            xk(j)=xk1(j)
         enddo
         ek = ek1
      enddo

      write(6,*)''
      write(6,*)'$B2r(B'
      write(6,'(a3,f10.5)')'x=',xk(1)
      write(6,'(a3,f10.5)')'y=',xk(2)
      if (n==3) then
      write(6,'(a3,f10.5)')'z=',xk(3)
      endif
      go to 20
   10 write(6,*)''
      write(6,*)'$B<}B+$7$J$$$?$a2r$O5a$^$i$J$$(B'  
      go to 20
   20 continue  
      return
  100 format(1x,i2,1x,a3,1x,f8.4,1x,f8.4,1x,f8.4,1x,f8.4) 
  200 format(1x,i2,1x,a3,1x,f8.4,1x,f8.4,
     -       1x,a3,1x,f8.4) 
  300 format(1x,i2,1x,a3,1x,f8.4,1x,f8.4,1x,f8.4,
     -       1x,a3,1x,f8.4) 
  400 format(1x,'$BH?I|2s?t(B',i2) 
      end
