Указатели, динамически формируемые массивы и строки, страница 5

   ReadLn (Width, Height);

   GetMem (Matrix, Width);

   For a:=1 To Width do

      Begin

      GetMem (Matrix^[a],Height);

      For b:=1 To Height Do

         Begin

         Write ('[',a,', ',b,'] = ');

         ReadLn (Matrix^[a]^[b]);

         End;

      End;

   Repeat

      Changes:=0;

      For a:=1 To Width-1 Do

         If Matrix^[a]^[Height]<Matrix^[a+1]^[Height] Then

            Begin

            Changes:=0;

            tmpColumn:=Matrix^[a];

            Matrix^[a]:=Matrix^[a+1];

            Matrix^[a+1]:=tmpColumn;

            End;

   Until Changes=0;

   For a:=1 To Height Do

      Begin

      For b:=1 To Width Do

         Write (Matrix^[b]^[a],' ');

      WriteLn;

      End;

   FreeMem (Matrix, Width*Height)

End.