diff options
Diffstat (limited to 'odd_even.adb')
-rw-r--r-- | odd_even.adb | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/odd_even.adb b/odd_even.adb deleted file mode 100644 index 095850e..0000000 --- a/odd_even.adb +++ /dev/null @@ -1,55 +0,0 @@ - - -package body Odd_Even is - - - procedure Swap(A, B : in out Element_T) is - Temp : Element_T; - begin - Temp := A; - A := B; - B := Temp; - end Swap; - - - procedure Single(Arr : in out Array_T) is - Sorted : Boolean; - begin - if Arr'Length <= 1 then - return; - end if; - - loop - Sorted := True; - - declare - I : Integer := Index_T'Pos(Arr'First); - begin - while I < Index_T'Pos(Arr'Last) loop - if Arr(Index_T'Val(I)) > Arr(Index_T'Val(I+1)) then - Swap( Arr(Index_T'Val(I)), Arr(Index_T'Val(I+1)) ); - Sorted := False; - end if; - I := I + 2; - end loop; - end; - - declare - I : Integer := Index_T'Pos(Arr'First) + 1; - begin - while I < Index_T'Pos(Arr'Last) loop - if Arr(Index_T'Val(I)) > Arr(Index_T'Val(I+1)) then - Swap( Arr(Index_T'Val(I)), Arr(Index_T'Val(I+1)) ); - Sorted := False; - end if; - I := I + 2; - end loop; - end; - - exit when Sorted; - end loop; - end Single; - - -end Odd_Even; - |