{$D-,L-,Y-,N-,E-,R-,S-,I-,Q-}
program BladzeniePrzypadkoweGraph;
uses graph,crt;

const
  KWADRAT=30; {'Bok' kwadratu.}
  Color100 : FillPatternType = ($FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF);

var
  tabl : array[0..((KWADRAT*KWADRAT)-1)] of real;
  colors : array[0..((KWADRAT*KWADRAT)-1)] of byte;

procedure CzytajDane;

var
  f : text;
  i : integer;
  tmp : integer;

begin
  i:=0;
  assign(f,'dane.txt');
  reset(f);
  while not eof(f) do
    begin
      readln(f,tabl[i]);
      inc(i);
    end;
  close(f);
  for i:=0 to (KWADRAT*KWADRAT)-1 do
    begin
      tmp:=trunc(tabl[i]*10000);
      if tmp=0 then colors[i]:=0;
      if (tmp >= 1) and (tmp <= 4) then colors[i]:=1;
      if (tmp >= 5) and (tmp <= 8) then colors[i]:=2;
      if (tmp >= 9) and (tmp <= 12) then colors[i]:=3;
      if (tmp >= 13) and (tmp <= 16) then colors[i]:=4;
      if (tmp >= 17) and (tmp <= 20) then colors[i]:=5;
      if (tmp >= 21) and (tmp <= 24) then colors[i]:=6;
      if (tmp >= 25) and (tmp <= 28) then colors[i]:=7;
      if (tmp >= 29) and (tmp <= 32) then colors[i]:=8;
      if (tmp >= 33) and (tmp <= 37) then colors[i]:=9;
      if (tmp >= 38) and (tmp <= 41) then colors[i]:=10;
      if (tmp >= 42) and (tmp <= 45) then colors[i]:=11;
      if (tmp >= 46) and (tmp <= 49) then colors[i]:=12;
      if (tmp >= 50) then colors[i]:=15;
    end;
end;

procedure Graf;

var
  x,y : integer;
  i,j,z,Driver,Mode : integer;

begin
  z:=0;
  Driver:=Detect;
  InitGraph(Driver,Mode,'.');
  Rectangle(0,0,GetMaXX,GetMaxY);
  for i:=1 to KWADRAT do
    begin
      x:=round(i*GetMaxX/KWADRAT);
      y:=round(i*GetMaxY/KWADRAT);
      Line(x,1,x,GetMaxY);
      Line(1,y,GetMaxX,y);
    end;
  for j:=0 to KWADRAT-1 do
    begin
      for i:=0 to KWADRAT-1 do
        begin
          SetFillPattern(Color100,colors[z]);
          inc(z);
          x:=round(i*GetMaxX/KWADRAT)+2;
          y:=round(j*GetMaxY/KWADRAT)+2;
          FloodFill(x,y,White);
        end;
    end;
  readkey;
  CloseGraph;
end;

begin
  CzytajDane;
  Graf;
end.
