Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for i := 0 to N - 1 do
- begin
- Bool[i] := false;
- Pos[i] := 0;
- end;
- while(true) do
- begin
- for I := 0 to N - 1 do
- begin
- c:= 0;
- for j := 0 to N - 1 do
- begin
- if(Bool[j]) then
- continue
- else
- begin
- if c = Pos[i] then
- begin
- Write(j+1);
- Write(' ');
- Bool[j] := true;
- break;
- end
- else c:= c + 1;
- end;
- end;
- end;
- WriteLn;
- e := true;
- for I := N - 2 downto 0 do
- begin
- if(Pos[i] < n - 1 - i) then
- begin
- Pos[i] := Pos[i] + 1;
- for J := I + 1 to N do
- Pos[j] := 0;
- e:= false;
- break;
- end;
- end;
- if(e) then break;
- for I := 0 to N do
- Bool[i] := false;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement