home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Distributions / ucb / spencer_2bsd.tar.gz / 2bsd.tar / src / pascal / tests / ancestor.p next >
Text File  |  1980-02-17  |  647b  |  25 lines

  1. program ancestor(output);
  2. {R.W.Floyd: 'Ancestor', Comm.ACM 6-62 and 3-63, Alg.96}
  3.   const n = 20;
  4.   var i,j,k: integer;
  5.       r: array [1..n, 1..n] of boolean;
  6. begin { r[i,j] = "i is a parent of j"}
  7.   for i := 1 to n do
  8.     for j := 1 to n do r[i,j] := false;
  9.   for i := 1 to n do
  10.     if i mod 10 <> 0 then r[i,i+1] := true;
  11.   writeln(wallclock);
  12.   for i := 1 to n do
  13.     for j := 1 to n do
  14.       if r[j,i] then
  15.         for k := 1 to n do
  16.           if r[i,k] then r[j,k] := true;
  17.   writeln(wallclock);
  18.   for i := 1 to n do
  19.   begin write(' ');
  20.     for j := 1 to n do write(chr(ord(r[i,j])+ord('0')));
  21.     writeln
  22.   end ;
  23.   writeln(wallclock)
  24. end .
  25.