var
i:integer;
n,col:longint;
a:array[1..3] of integer;
b:array[0..9] of integer;
procedure rec(t:integer);
var i:integer;
begin
if t=4 then begin
inc(col);
for i:=1 to 3 do
write(a[i]);
writeln();
exit;
end;
for i:=0 to 9 do
if b[i]>0 then begin
dec(b[i]);
a[t]:=i;
rec(t+1);
inc(b[i]);
write('Число: ');
read(n);
while(n>0) do begin
inc(b[n mod 10]);
n:=n div 10;
for i:=1 to 9 do
a[1]:=i; dec(b[i]);
rec(2);
writeln('Количество: ', col);
end.
var
i:integer;
n,col:longint;
a:array[1..3] of integer;
b:array[0..9] of integer;
procedure rec(t:integer);
var i:integer;
begin
if t=4 then begin
inc(col);
for i:=1 to 3 do
write(a[i]);
writeln();
exit;
end;
for i:=0 to 9 do
if b[i]>0 then begin
dec(b[i]);
a[t]:=i;
rec(t+1);
inc(b[i]);
end;
end;
begin
write('Число: ');
read(n);
while(n>0) do begin
inc(b[n mod 10]);
n:=n div 10;
end;
for i:=1 to 9 do
if b[i]>0 then begin
a[1]:=i; dec(b[i]);
rec(2);
inc(b[i]);
end;
writeln('Количество: ', col);
end.