Triangle tools from the text book Programming Processors in Java.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
Triangle-Tools/programs/control.tri

26 lines
477 B

! Plot a histogram from a stream of nonzero integers.
let
const mark ~ '+';
var n : Integer
in
begin
getint (var n); geteol ();
while n \= 0 do
let
var i : Integer;
var gap : Integer
in
begin
gap := if n > 0 then 20 else 20 + n;
if n < 0 then n := 0 - n else ;
i := 0;
while i < gap do
begin put (' '); i := i + 1 end;
i := 0;
while i < n do
begin put (mark); i := i + 1 end;
puteol ();
getint (var n); geteol ()
end
end