Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
35
Task/Executable-library/Ada/executable-library-4.ada
Normal file
35
Task/Executable-library/Ada/executable-library-4.ada
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
with Hailstone, Parameter, Ada.Text_IO;
|
||||
|
||||
procedure Hailstone_Test is
|
||||
Counts: array (1 .. 100_000) of Natural := (others => 0);
|
||||
Max_Count: Natural := 0;
|
||||
Most_Common: Positive := Counts'First;
|
||||
Length: Natural renames Parameter.Y;
|
||||
Sample: Natural := 0;
|
||||
begin
|
||||
for I in Counts'Range loop
|
||||
Parameter.X := I;
|
||||
Hailstone; -- compute the length of Hailstone(I)
|
||||
Counts(Length) := Counts(Length)+1;
|
||||
end loop;
|
||||
for I in Counts'Range loop
|
||||
if Counts(I) > Max_Count then
|
||||
Max_Count := Counts(I);
|
||||
Most_Common := I;
|
||||
end if;
|
||||
end loop;
|
||||
Ada.Text_IO.Put_Line("Most frequent length:"
|
||||
& Integer'Image(Most_Common)
|
||||
& ";" & Integer'Image(Max_Count)
|
||||
& " sequences of that length.");
|
||||
for I in Counts'Range loop
|
||||
Parameter.X := I;
|
||||
Hailstone; -- compute the length of Hailstone(I)
|
||||
if Length = Most_Common then
|
||||
Sample := I;
|
||||
exit;
|
||||
end if;
|
||||
end loop;
|
||||
Ada.Text_IO.Put_Line("The first such sequence: Hailstone("
|
||||
& Integer'Image(Sample) & " ).");
|
||||
end Hailstone_Test;
|
||||
Loading…
Add table
Add a link
Reference in a new issue