program Project2; {$APPTYPE CONSOLE} {$o-} uses SysUtils; var x1,x2,x3,x4,x5:byte; procedure tri(z1,z2,z3,z4,z5:byte); var a:array[0..1000,0..1000] of integer; b:array[1..100000] of byte; n:integer; min,max,jj,ii:integer; boo:boolean; function check:boolean; var i,i1,i2,i3,i4:integer; j: Integer; procedure stop; begin check:=false; end; begin i1:=n-1; for I := 2 to n do begin for i2 := 1 to i1 do begin a[i,i2]:=abs(a[i-1,i2]-a[i-1,i2+1]); if a[i,i2]=0 then begin stop; exit; end; end; dec(i1); end; for I := 1 to n do for j := 1 to n do begin if a[i,j]<>0 then begin if b[a[i,j]]<>1 then b[a[i,j]]:=1 else begin stop; exit; end; end; end; check:=true; end; begin n:=5; fillchar(b,sizeof(b),0); fillchar(a,sizeof(a),0); a[1,1]:=z1; a[1,2]:=z2; a[1,3]:=z3; a[1,4]:=z4; a[1,5]:=z5; if check then begin max:=0; for jj := 1 to n do for ii := 1 to n do if (a[jj,ii]>max) then max:=a[jj,ii]; min:=maxint; for jj := 1 to n do for ii := 1 to n do if (a[jj,ii]0) then min:=a[jj,ii]; write(max-min,' - '); for ii := 1 to n do write(a[1,ii]); writeln; end else begin writeln('Wrong!!!'); end; end; begin reset(output,'output.txt'); rewrite(output); for x1 := 1 to 10 do for x2 := 1 to 10 do for x3 := 1 to 10 do for x4 := 1 to 10 do for x5 := 1 to 10 do tri(x1,x2,x3,x4,x5); close(input); end.