Floyd's triangle: Difference between revisions

Content added Content deleted
m (→‎{{header|Ada}}: fixed a minor bug)
Line 23: Line 23:
Rows: constant Positive := Integer'Value(Ada.Command_Line.Argument(1));
Rows: constant Positive := Integer'Value(Ada.Command_Line.Argument(1));
Last_Number:constant Positive := (Rows * (Rows+1)) / 2;
Last_Number:constant Positive := (Rows * (Rows+1)) / 2;

Width: array(1 .. Rows) of Positive;

Current: Positive := 1;
Current: Positive := 1;
Width: array(1 .. Rows) of Positive;


begin
begin
-- compute the width for the different columns
for I in Width'Range loop
for I in Width'Range loop
Width(I) := Integer'Image(I + (Rows * (Rows-1))/2)'Length;
Width(I) := Integer'Image(I + (Rows * (Rows-1))/2)'Length;
end loop;
end loop;
-- output the triangle
for Line in 1 .. Rows loop
for Line in 1 .. Rows loop
for Column in 1 .. Line loop
for Column in 1 .. Line loop