procedure glow(beginx,endx: integer;);
var
x1,x2,x3,y1,y2,y3,z1,z2,z3,cou,glow: integer;
s1,s2,s3,s4,strresult: string;
begin
cou:=0;
glow:=beginx;
while (cou<(endx+1)-beginx) or (cou<(beginx+1)-endx) do
begin
// условия циклов
if glow<=1 then y1:=0 else y1:=0;
if glow<=1 then z1:=9 else z1:=0;
if glow<=2 then y2:=0 else y2:=0;
if glow<=2 then z2:=9 else z2:=0;
if glow<=3 then y3:=0 else y3:=0;
if glow<=3 then z3:=9 else z3:=0;
// условия промежуточных строк
if glow<=1 then s1:='(' else s1:='';
if glow<=2 then s2:=',' else s2:='';
if glow<=3 then s3:=',' else s3:='';
if glow<=1 then s4:=')' else s4:='';
// Циклы
for x1:=y1 to z1 do
for x2:=y2 to z2 do
for x3:=y3 to z3 do
// условия результата
if (x1+x2+x3>0) then
begin
// формирование результата
strresult:=s1+inttostr(x1)+s2+inttostr(x2)+s3+inttostr(x3)+s4;
// вывод результата
form1.memo1.lines.add(strresult);
end;
end;
// переход на следующий уровень
if beginx<=endx
then glow:=glow+1
else glow:=glow-1;
cou:=cou+1;
end;