Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
30
Task/Combinations/Pascal/combinations.pas
Normal file
30
Task/Combinations/Pascal/combinations.pas
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
Program Combinations;
|
||||
|
||||
const
|
||||
m_max = 3;
|
||||
n_max = 5;
|
||||
var
|
||||
combination: array [0..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