September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -1,23 +1,12 @@
with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Command_Line;
procedure Floyd_Triangle is
Rows: constant Positive := Integer'Value(Ada.Command_Line.Argument(1));
Current: Positive := 1;
Width: array(1 .. Rows) of Positive;
rows : constant Natural := Natural'Value(Ada.Command_Line.Argument(1));
begin
-- compute the width for the different columns
for I in Width'Range loop
Width(I) := Integer'Image(I + (Rows * (Rows-1))/2)'Length;
end loop;
-- output the triangle
for Line in 1 .. Rows loop
for Column in 1 .. Line loop
Ada.Integer_Text_IO.Put(Current, Width => Width(Column));
Current := Current + 1;
end loop;
Ada.Text_IO.New_Line;
end loop;
for r in 1..rows loop
for i in 1..r loop
Ada.Integer_Text_IO.put (r*(r-1)/2+i, Width=> Natural'Image(rows*(rows-1)/2+i)'Length);
end loop;
Ada.Text_IO.New_Line;
end loop;
end Floyd_Triangle;