回复 18楼 冰镇柠檬汁儿
应该是比你厉害很多吧,调用 html 函数的几行代码也发来发去,感觉是第一天写代码一样

我就是真命天子,顺我者生,逆我者死!
程序代码:
#include <stdio.h>
#include <string.h>
int a[] = {1, 2, 3, 4, 5};
void recursion(int* combination, int m, int n, int begin, int depth);
int main(void)
{
int m = sizeof(a) / sizeof(a[0]);
int n = 2;
int* combination = (int*)malloc(sizeof(int) * m);
recursion(combination, m, n, 1, 1);
getchar();
return 0;
}
void recursion(int* combination, int m, int n, int begin, int depth)
{
int i, j;
for (i = begin; i <= m; i++)
{
combination[depth] = i;
if (depth == n)
{
for (j = 1; j <= n; j++)
{
printf("%d ", a[combination[j]-1]);
}
printf("\n");
}
else
{
recursion(combination, m, n, i+1, depth+1);
}
}
}
