def get_arrange_no_sort(n, r) :
result = []
result.append(range(1, r+1))
for i in range(r+1, n+1) :
tmp = []
for item in result :
for index in range(0, 3) :
tmp2 = []
if index == 2 :
tmp2.append(item[0])
tmp2.append(item[2])
else :
tmp2.append(item[index])
tmp2.append(item[index+1])
tmp2.append(i)
tmp.append(tmp2)
result.extend(tmp)
return result
if __name__ == '__main__' :
result = get_arrange_no_sort(6, 3)
print len(result)
for item in result :
print item
#include <stdio.h>
#include <malloc.h>
//int j = 0;
typedef struct
{
int *store; //save the value of the array argument
int *headlist; //save the first address of the array argument
int numofcmb; //save the value of "list_len"
}T_DATA_STORE;
void Combinationrecursion(int * ,int , int ,T_DATA_STORE *);
//***********************************************************************************
//Function :
// Combination():difining variable and using Combinationrecursion() funcion
//Argument :
// *list : the address of the array argument
// list_len : the number of the array argument
// cmb : the number of the combination
//Return value:
// void
//***********************************************************************************
void Combination(int *list,int list_len, int cmb)
{
T_DATA_STORE t;
t.store = (int *)malloc((cmb) * sizeof(int));
t.headlist = list;
t.numofcmb = cmb;
//***********************************************************************************
//Function :
// recursion():count Combination of the recursion
//Argument :
// *list : the address of the array argument
// list_len : the number of the array argument
// cmb : the number of the combination
// *save : the struct save the value of the array and the first address
// of the array and the list_len
//Return value :
// void
//***********************************************************************************
void Combinationrecursion(int * list,int list_len, int cmb, T_DATA_STORE *save)
{
int i = 0;