From b90a6de5470df5771c1b3ade5b6f1f4780be874d Mon Sep 17 00:00:00 2001 From: davidly Date: Mon, 8 Jul 2024 14:02:30 -0700 Subject: [PATCH] better output formatting --- Artek Ada v125/E.ADA | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Artek Ada v125/E.ADA b/Artek Ada v125/E.ADA index 4bf1a87..5104e11 100644 --- a/Artek Ada v125/E.ADA +++ b/Artek Ada v125/E.ADA @@ -2,15 +2,15 @@ with TEXT_IO; use TEXT_IO; procedure E is -h, n, x, d, y : integer; +package INTIO is new INTEGER_IO (INTEGER); + +h, n, x, y : integer; a : Array(0..200) of integer; begin h := 200; x := 0; n := h - 1; - d := 0; - y := 0; Put( "starting... " ); New_line; while n > 0 loop @@ -25,14 +25,18 @@ begin h := h - 1; n := h; while 0 /= n loop - -- math simplified because complex expressions cause bad code to be generated a( n ) := x REM n; + -- math simplified using local y because complex expressions cause bad code to be generated y := a( n - 1 ); x := ( y * 10 ) + ( x / n ); n := n - 1; end loop; - Put( INTEGER'IMAGE( x ) ); + if ( x >= 10 ) then + INTIO.PUT( x, 2 ); + else + INTIO.PUT( x, 1 ); + end if; end loop; New_line;