|
|
1.1 root 1: {$p+}
2: program initable(input,output);
3: type counter=0..4;
4: object=1..4;
5: container=set of object;
6: row=array[1..4]of 1..4;
7: var sol:row; i,j,k:integer;
8: table:array[1..24]of row;
9:
10: procedure select(bag:container; sample,drawn:counter);
11: {Generation of permutations in lexicographic order,
12: adapted from Grogono, page 134.}
13: var ball:object;
14: begin
15: if drawn<sample then
16: for ball:=1 to 4 do
17: if ball in bag then begin sol[drawn+1]:=ball;
18: select(bag-[ball],sample,drawn+1)
19: end;
20: if drawn=sample then begin table[k]:=sol; k:=k+1 end
21: end; {of select}
22:
23: begin {of initable}
24: k:=1;
25: select([1..4],4,0);
26: for i := 1 to k-1 do begin
27: write('table[', i:1, '] = ');
28: for j := 1 to 4 do
29: write(table[i][j]);
30: writeln;
31: end;
32: end.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.