home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / sampler / 02 / sort / sorttest.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1988-03-01  |  731 b   |  37 lines

  1. PROGRAM SORTTEST;
  2.  
  3. CONST Limit = 1000;
  4.  
  5. VAR count : Word;
  6.     List : ARRAY[1..Limit] OF Integer;
  7.  
  8. procedure Sort;
  9. {
  10.    preconditions:  List is an array[1..Limit] of Integer
  11.                    Count is of type Word
  12.                      and in the range 0..Limit
  13.    postconditions: The elements 1..Count of List are sorted
  14.                      in ascending order
  15. }
  16. var
  17.   Top,Min,K,Temp : Integer;
  18. begin
  19.   for Top := 1 to Count-1 do begin
  20.     Min := Top;
  21.     for K := Top+1 to Count do
  22.       if List[K] < List[Min]
  23.         then Min := K;
  24.     if Top <> Min then begin
  25.       Temp := List[Top];
  26.       List[Top] := List[Min];
  27.       List[Min] := Temp
  28.     end
  29.   end
  30. end; { of proc Sort }
  31.  
  32.  
  33.  
  34.  
  35. BEGIN
  36. END.
  37.