Mai intai trebuie sa te autentifici.
Cod sursa(job #322766)
| Utilizator | Data | 9 iunie 2009 19:36:20 | |
|---|---|---|---|
| Problema | Generare de permutari | Scor | 20 |
| Compilator | fpc | Status | done |
| Runda | Arhiva educationala | Marime | 0.6 kb |
Program P1;
var n : longint;
s : array[1..10] of longint;
f,g : text;
Procedure permut(k : longint);
var i,j : longint;
ok : boolean;
begin
if k=n then begin
for i:=1 to n do write(g,s[i]);
writeln(g);
end
else
begin
for i:=1 to n do begin
begin
ok:=true;
for j:=1 to k do
if s[j]=i then
begin
ok:=false;
break;
end;
if ok then
begin
s[k+1]:=i;
permut(k+1);
end;
end;
end;
end;
end;
begin
assign(f,'permutari.in');
reset(f);
readln(f,n);
close(f);
assign(g,'permutari.out');
rewrite(g);
permut(0);
close(g);
end.
