Не уверен, что написал все верно, так как программа смогла найти только одну такую пару чисел, но все же...
954 - 459 = 495
program P1; uses crt; var i,j,k,n,x,y,z : integer; begin
clrscr;
for i := 1 to 9 do begin
for j := 0 to 9 do begin
if i = j then continue;
for k := 0 to 9 do begin
if (j = k) or (i = k) then continue;
if k*100+j*10+i < 100 then continue;
n := (i*100+j*10+k) - (k*100+j*10+i);
if n > 100 then begin
x := n div 100; y := (n - x * 100) div 10; z := n - (x*100+y*10);
if ((x = i) and (y = j) and (z = k)) or ((x = i) and (y = k) and (z = j)) or ((x = j) and (y = i) and (z = k)) or ((x = j) and (y = k) and (z = i)) or ((x = k) and (y = j) and (z = i)) or ((x = k) and (y = i) and (z = j)) then
program P1;
uses
crt;
var
mas : array[1..20] of integer;
i,j,k : integer;
tmp : string;
begin
clrscr;
writeln('Start array: ');
for i := 1 to 20 do
begin
mas[i] := random(100);
write(mas[i],' ');
end;
for i := 1 to 20 do
begin
if mas[i] mod 2 = 0 then
mas[i] := 0;
end;
for i := 1 to 20 do
begin
if mas[i] = 0 then
begin
for j := 20 downto i do
if mas[j] <> 0 then
begin
k := mas[j];
mas[j] := mas[i];
mas[i] := k;
end;
end;
end;
writeln('');
writeln('Result array: ');
for i := 1 to 20 do
write(mas[i],' ');
readln(tmp);
read(tmp);
end.
Не уверен, что написал все верно, так как программа смогла найти только одну такую пару чисел, но все же...
954 - 459 = 495
program P1;
uses
crt;
var
i,j,k,n,x,y,z : integer;
begin
clrscr;
for i := 1 to 9 do
begin
for j := 0 to 9 do
begin
if i = j then
continue;
for k := 0 to 9 do
begin
if (j = k) or (i = k) then
continue;
if k*100+j*10+i < 100 then
continue;
n := (i*100+j*10+k) - (k*100+j*10+i);
if n > 100 then
begin
x := n div 100;
y := (n - x * 100) div 10;
z := n - (x*100+y*10);
if ((x = i) and (y = j) and (z = k)) or
((x = i) and (y = k) and (z = j)) or
((x = j) and (y = i) and (z = k)) or
((x = j) and (y = k) and (z = i)) or
((x = k) and (y = j) and (z = i)) or
((x = k) and (y = i) and (z = j)) then
writeln(i*100+j*10+k,' - ',k*100+j*10+i,' = ',n);
end;
end;
end;
end;
readln;
readln;
end.