我反着递怕新手看不懂,
#include <stdio.h>
#define NUM 3
int a[NUM+1] = {0};
void combination(int m, int k, int depth)
{
int i, j;
for(i = m; i >= k; i--)
{
a[k] = i;
if (k == 1)
{
for (j = 1; j <= 3; j++)
printf ("%d ",a[j]);
printf ("\n");
}
else
{
combination(i-1, k-1, depth+1);
}
}
}
int main(void)
{
combination(5, NUM, 0);
getchar();
return
0;
}