分类:
2010-09-09 14:36:00
#include
#define IN
#define OUT
#define ARRAY_SIZE 7
#define SELECT_NUM 3
using std::cout;
using std::endl;
template
void PermAndComb(const T *arr, const int size, const int len, int index = 0)
{
int *arrResult = new int[len];
for(int i=0; i
while(true){
int cur = len - 2;
while(arrResult[len-1]
arrResult[len-1]++;
}
for(; cur>=0; cur--){
if(arrResult[cur]+1
for(int i=cur+1; i
break;
}
}
if(cur<0){
delete []arrResult;
return;
}
}
}
template
void Display(const T *arr, const int *arrIndex, const int size)
{
for(int i=0; i
cout << endl;
}
int main(void)
{
int arr[ARRAY_SIZE];
for(int i=0; i
PermAndComb(arr, ARRAY_SIZE, SELECT_NUM);
return 0;
}