REM sweeping method
DATA 4               
DATA   3,  9, 12, -6
DATA   1,  3,  4,  5
DATA   5,  6, 11,-37
DATA   1,  5, -4,  2
DECLARE NUMERIC i,j,k,s,t,u,g,determ
DIM A(10,10)   
READ s
MAT READ A(s,s)
MAT PRINT A;
LET determ=1
FOR k=1 TO s
! pivotting
   LET i=k
   DO WHILE i<=s AND A(i,k)=0 
      LET i=i+1
   LOOP
   IF i>s THEN
      LET determ=0
      EXIT FOR
   ELSEIF i<>k THEN
      PRINT "Exchange line"; i; "and line"; k
      LET determ=-determ
      FOR j=1 TO s 
         LET t=A(i,j)
         LET A(i,j)=A(k,j)
         LET A(k,j)=t
      NEXT j
      MAT PRINT A;
   END IF
   !
   LET t=A(k,k)
   PRINT "Divide line"; k; "by "; t
   LET determ=determ*t
   FOR i=1 TO s
      LET A(k,i)=A(k,i)/t
   NEXT i
   MAT PRINT A;
   FOR j=k+1 TO s
      LET u=A(j,k)
      PRINT "subtract line"; k; "multiplied by"; u ; "from line"; j
      FOR i=1 TO s
         LET A(j,i)=A(j,i)-A(k,i)*u
      NEXT i
   NEXT j  
   MAT PRINT A;
NEXT k
PRINT determ  
END
 
