--
-- This is a test of run-time array bounds checking.
--
package test24 is body
    type matrix is array [1..10] of array [1..2] of float;
    b : matrix;
    x : float;
    i, j, k : integer; 
begin 
    read (i); 
    j := 0;
    loop 
        j := j + 1; 
        read (b[j][1]); b[j][2] := b[j][1];
        exit when i == j;
    end loop;
    j := 1;
    loop 
        k := j; 
        loop
            if b[j][1] > b[k][1] then
                x := b[k][1]; b[k][1] := b[j][1]; b[j][1] := x; 
            elsif k <= 10 then k := k + 1;  -- this should be < not <=
            else exit; 
            end if;
        end loop; 
        exit when j == 10; 
        j := j + 1; 
    end loop;
    j := 1;
    write ("the original and sorted lists are:");
    write ("");
    loop 
        write (b[j][2], b[j][1]); j := j + 1; 
        exit when j == 11; 
    end loop;
end.
