dos_compilers/Artek Ada v125/E.ADA

47 lines
905 B
Plaintext
Raw Normal View History

2024-07-08 18:31:49 +02:00
with TEXT_IO; use TEXT_IO;
procedure E is
2024-07-08 23:02:30 +02:00
package INTIO is new INTEGER_IO (INTEGER);
h, n, x, y : integer;
2024-07-08 18:31:49 +02:00
a : Array(0..200) of integer;
begin
h := 200;
x := 0;
n := h - 1;
Put( "starting... " ); New_line;
while n > 0 loop
a( n ) := 1;
n := n - 1;
end loop;
a( 1 ) := 2;
a( 0 ) := 0;
while h > 9 loop
h := h - 1;
n := h;
while 0 /= n loop
a( n ) := x REM n;
2024-07-08 23:02:30 +02:00
-- math simplified using local y because complex expressions cause bad code to be generated
2024-07-08 18:31:49 +02:00
y := a( n - 1 );
x := ( y * 10 ) + ( x / n );
n := n - 1;
end loop;
2024-07-08 23:02:30 +02:00
if ( x >= 10 ) then
INTIO.PUT( x, 2 );
else
INTIO.PUT( x, 1 );
end if;
2024-07-08 18:31:49 +02:00
end loop;
New_line;
Put( "done" );
New_line;
end e;