Program Normal;
 
 Var I : Integer;
     Y1, Y2 : Real;
     Freq : Array[0..30] of Integer;
 
 Procedure Initialize;
   Var I : integer;
   Begin
     For i:= 0 to 30 do Freq[i] := 0
   End;
 
 
 Procedure Classify (Y: Real);
   Const MinY = -3.5;
         YRange = 7.0;
         NbClasses = 30;
   Var Temp : Integer;
   Begin
     Temp := Trunc((Y-MinY)/YRange*NbClasses);
     If Temp < 1 then Temp := 0
                 else if Temp > NbClasses then Temp := 
                 NbClasses;
     Freq[Temp] := Freq[Temp] + 1
   End;
 Procedure NorDev (Var Y1, Y2 : Real);
   Var V1, V2, S : Real;
   Begin
   { The "Repeat until" loop is repeated 1.27 times 
          on the average with a standard deviation 
          of 0.587 (c.f. D. Knuth (1969), page 104) }
     Repeat
       V1 := 2*Random -1;
       V2 := 2*Random -1;
       S := Sqr(V1) + Sqr(V2)
      until S < 1;
     S := Sqrt(-2*ln(S)/S);
     Y1 := V1*S;
     Y2 := V2*S
   End;

Begin
  Initialize;
  For i:= 1 to 5000 do
    Begin
      NorDev(Y1,Y2);
      Classify(Y1);
      Classify(Y2)
    End;
  For i:=0 to 30 do
     Writeln(I:6,Freq[I]:12)
End.
