Display histogram with 50 columns
Delphi & Pascal (česká wiki)
Category: KMP (Club of young programmers)
Author: Ján Benkovič
web: www.tbteacher.host.sk
Program: Histogram.pas
File exe: Histogram.exe
Author: Ján Benkovič
web: www.tbteacher.host.sk
Program: Histogram.pas
File exe: Histogram.exe
Program generate array of 50 number from interval <1,20>. Program print histogram 50 columns of char *, every column is high like is a number. Don't use GotoXY, assume that number are correct.
{ HISTO.PAS Copyright (c) Jan Benkovic } { Dane je 50 prvkove pole z intervalu <1,20>. Napiste program, } { ktory vytlaci histogram : 50 stlpcov zo znakov *, pricom kazdy } { stlpec je vysoky podla prislusnej hodnoty v poli. } { Nepouzivajte GotoXY, predpokladajme ze hodnoty su korektne. } { } { Datum:12.04.2002 http://www.trsek.com } uses crt; var pole : array[1..50] of byte; a,b : byte; begin clrscr; randomize; { vygeneruje pole hviezdiciek } for a:= 1 to 50 do pole[a]:=random(20)+1; { vykresli pole hviezdiciek } for a:= 20 downto 1 do begin for b:= 1 to 50 do begin if pole[b]>=a then Write('*') else Write(' '); end; Writeln; end; readkey; end.