Листинг программы
program z14;
{Вводится слово из N различных букв (N<10).
Получить все возможные слова из S букв этого слова(S<=N)}
uses crt,graph;
var do1,po1,a,i1:string;s,i2,do2,po2,i,j,k,l,m,fl1,fl2,n:longint;
er:integer;b:array[1..100]of longint;
begin
clrscr;textcolor(10);
write('Введите слово:');readln(a);
write('Введите длину нужных вам слов:');readln(s);
n:=length(a);
if n>9 then beginwrite('ОШИБКА!!! n<10 ');readln;halt;end;
if s>n then beginwrite('ОШИБКА!!! s<=n ');readln;halt;end;
for i:=1 to s do do1:=do1+'0';
for i:=1 to s do po1:=po1+'9';
do1[1]:='1';val(do1,do2,er);val(po1,po2,er);j:=0;
for i:=do2 to po2 do
begin
str(i,i1);fl1:=0;fl2:=0;
for m:=1 to length(i1) do
begin
val(i1[m],i2,er);
if (n<i2)or(i2=0)then fl2:=1;
end;
for l:=1 to s-1 do
for k:=l+1 to s do
if (i1[l]=i1[k])or(fl2=1)then fl1:=1;
if fl1=0 then begin
inc(j);b[j]:=i;
end;
end;
for i:=1 to j do
begin
str(b[i],do1);
for k:=1 to length(i1)do
begin
if do1[k]='1'then write(a[1]);
if do1[k]='2'then write(a[2]);
if do1[k]='3'then write(a[3]);
if do1[k]='4'then write(a[4]);
if do1[k]='5'then write(a[5]);
if do1[k]='6'then write(a[6]);
if do1[k]='7'then write(a[7]);
if do1[k]='8'then write(a[8]);
if do1[k]='9'then write(a[9]);
end;write(' ');
end;readln;
end.