void Dfs(int a[], int end, int start) { if (start == end-1) { for (int j = 0; j<end; j++) printf("%d ",a[j]); printf("/n"); return; } for (int j = start; j<end ; j++) { int temp = a[j]; a[j] = a[start]; a[start] = temp; Dfs(a, end, start+1); temp = a[start]; a[start] = a[j]; a[j] = temp; } } // permutation void Permutation_Recusive(int n) { for (int i=0; i<n; i++) { a[i] = i+1; } Dfs(a, n, 0); }