Jumat, Juni 10, 2016

Pascal Programming of Pascal's Triangle

var
  b,c,d:integer;
  a:array [1..255,1..255] of integer;

begin
write('input integer >=0 as binomial coefficients! '); readln(d);
for b:=1 to d+1 do
 begin writeln;
 for c:=1 to b do
  begin
   if (c=1) OR (c=d+1) then a[b,c]:=1 else
   a[b,c]:=a[b-1,c-1] + a[b-1,c];
   write(a[b,c],' ');
  end;
 end;
readln
end.

0 komentar: