#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#define MAX 6
void DFS(int *output, int val, int pos, bool *isSelected, int &k)
{
int i = 0;
if ( isSelected[val] )
{
return;
}
output[pos] = val;
isSelected[val] = true;
if ( pos == (MAX - 2) )
{
for (i = 0; i < MAX - 1; i++)
{
printf("%d ", output[i]);
}
printf("\n");
k++;
isSelected[val] = false;
return;
}
for (i = 1; i < MAX; i++)
{
DFS(output, i, pos + 1, isSelected, k);
}
isSelected[val] = false;
}
int main()
{
bool isSelected[MAX];
int output[MAX];
int i = 0;
int k = 0;
for (i = 1; i < MAX; i++)
{
memset(isSelected, false, sizeof(isSelected));
DFS(output, i, 0, isSelected, k);
}
printf("\n\n\nk = %d \n", k);
return 0;
}