langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
30
Task/Combinations/Pascal/combinations.pascal
Normal file
30
Task/Combinations/Pascal/combinations.pascal
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
Program Combinations;
|
||||
|
||||
const
|
||||
m_max = 3;
|
||||
n_max = 5;
|
||||
var
|
||||
combination: array [1..m_max] of integer;
|
||||
|
||||
procedure generate(m: integer);
|
||||
var
|
||||
n, i: integer;
|
||||
begin
|
||||
if (m > m_max) then
|
||||
begin
|
||||
for i := 1 to m_max do
|
||||
write (combination[i], ' ');
|
||||
writeln;
|
||||
end
|
||||
else
|
||||
for n := 1 to n_max do
|
||||
if ((m = 1) or (n > combination[m-1])) then
|
||||
begin
|
||||
combination[m] := n;
|
||||
generate(m + 1);
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
generate(1);
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue