这个问题你不是已经问过了吗?
program combin;
{$APPTYPE CONSOLE}
uses SysUtils;
var
cc: array [0..30] of byte;
flag : array [1..30] of 0..1;
M,N : integer;
procedure com(step:integer);
var
i,j : byte;
begin
if (step<=M) then
begin
for i:=1 to Ndo
if ((flag)=0) and (i>cc[step-1]) then
begin
flag:=1;
cc[step] := i;
com(step+1);
flag := 0;
end;
end
else
begin
for j:=1 to Mdo
write(cc[j],' ');
writeln;
end;
end;
begin
fillchar(flag,sizeof(flag),0);
N := 6;
M := 2;
cc[0] := 0;cc[1]:=1;
com(1);
readln;
// Insert user code here
end.