Треугольник Паскаля. Решение.

program paskalTreug;
var
a:array[1..15,1..15] of integer;
i,n,j:integer;
f,g:text;
begin
assign (f,'input.txt');
reset (f);
read(f,n);
close (f);

a[1,1]:=1;

For i:=2 to n+1 do
For j:=1 to n+1 do
If (j=1) or (j=i) then a[i,j]:=1
else a[i,j]:=a[i-1,j-1]+a[i-1,j];

assign (g,'output.txt');
rewrite (G);
For i:=1 to n+1 do begin
For j:=1 to n+1 do
If a[i,j]<> 0 then write (g,a[i,j],'   ');
writeln(g);
end;
close(g);
end.

Комментариев нет:

Отправить комментарий