home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / spezial / 02 / t2.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1986-02-05  |  848 b   |  37 lines

  1. program histogramm;
  2. const bildhoehe=19;
  3.       maxn     =25;
  4.       etwas    ='|';
  5.       nichts   =' ';
  6. type zahlen=array[1..maxn] of integer;
  7. var zahl:zahlen;
  8.     i,j,n,max,faktor:integer;
  9.     c:char;
  10.  
  11. begin
  12.   writeln('Histogramm fuer',' max ',maxn,' nat. Zahlen');
  13.   writeln('letzte Zahl < 0');
  14.   n:=0;
  15.    repeat
  16.     n:=n+1;
  17.     write('Bitte ',n,'-te Zahl',' eingeben --> ');
  18.     readln(zahl[n]);
  19.    until zahl[n]<0;
  20.    n:=n-1;
  21.   (* Skalierungsfaktor ermitteln *)
  22.   max:=zahl[1];
  23.   for i:=2 to n do
  24.    if zahl[i]>max then max:=zahl[i];
  25.   faktor:=(max-1) div bildhoehe+1;
  26.   (* Ausgabe *)
  27.   for i:=bildhoehe downto 1 do
  28.    begin
  29.     for j:=1 to n do
  30.      if (i-0.5)*faktor<=zahl[j] then write(etwas)
  31.                                 else write(nichts);
  32.      writeln;
  33.    end;
  34.   write(' press key ');
  35.   read(c);
  36. end.
  37.