Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,6 +0,0 @@
|
|||
generic
|
||||
type Element_Type is private;
|
||||
type Index is (<>);
|
||||
type Collection is array(Index) of Element_Type;
|
||||
with function "<=" (Left, Right : Element_Type) return Boolean is <>;
|
||||
procedure Gnome_Sort(Item : in out Collection);
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
procedure Gnome_Sort(Item : in out Collection) is
|
||||
procedure Swap(Left, Right : in out Element_Type) is
|
||||
Temp : Element_Type := Left;
|
||||
begin
|
||||
Left := Right;
|
||||
Right := Temp;
|
||||
end Swap;
|
||||
|
||||
I : Integer := Index'Pos(Index'Succ(Index'First));
|
||||
J : Integer := I + 1;
|
||||
begin
|
||||
while I <= Index'Pos(Index'Last) loop
|
||||
if Item(Index'Val(I - 1)) <= Item(Index'Val(I)) then
|
||||
I := J;
|
||||
J := J + 1;
|
||||
else
|
||||
Swap(Item(Index'Val(I - 1)), Item(Index'Val(I)));
|
||||
I := I - 1;
|
||||
if I = Index'Pos(Index'First) then
|
||||
I := J;
|
||||
J := J + 1;
|
||||
end if;
|
||||
end if;
|
||||
end loop;
|
||||
end Gnome_Sort;
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
with Gnome_Sort;
|
||||
with Ada.Text_Io; use Ada.Text_Io;
|
||||
|
||||
procedure Gnome_Sort_Test is
|
||||
type Index is range 0..9;
|
||||
type Buf is array(Index) of Integer;
|
||||
procedure Sort is new Gnome_Sort(Integer, Index, Buf);
|
||||
A : Buf := (900, 700, 800, 600, 400, 500, 200, 100, 300, 0);
|
||||
begin
|
||||
for I in A'range loop
|
||||
Put(Integer'Image(A(I)));
|
||||
end loop;
|
||||
New_Line;
|
||||
Sort(A);
|
||||
for I in A'range loop
|
||||
Put(Integer'Image(A(I)));
|
||||
end loop;
|
||||
New_Line;
|
||||
end Gnome_Sort_Test;
|
||||
Loading…
Add table
Add a link
Reference in a new issue