Pagini recente » Cod sursa (job #2128429) | Cod sursa (job #2952457) | Cod sursa (job #1374008) | Cod sursa (job #1926502) | Cod sursa (job #1747235)
type tablou=array [1..8] of 0..9 ;
var t:tablou;
i,j,k,m,n:integer;
b,boo:boolean;
f,g:text;
begin
assign(f,'permutari.in');
assign(g,'permutari.out');
reset(f);
rewrite(g);
read(f,n);
k:=1;
while k>0 do
begin
repeat
if t[k]<n then begin
t[k]:=t[k]+1;
b:=true;
end
else b:=false;
if b then begin
boo:=true;
for i:=1 to k-1 do
if t[i]=t[k] then boo:=false
end;
until (b and boo) or not(b) ;
if b then
if k=n then begin
for i:=1 to n do
write(g,t[i]);
writeln(g);
end
else begin
k:=k+1;
t[k]:=0;
end
else k:=k-1;
end;
close(f);
close(g);
end.