privatevoidGetPermute<T>(T[] list, int k, int m, Action<T[]> actAddPermute) { if (k == m) { actAddPermute?.Invoke(list); } else { for (int i = k; i <= m; i++) { Swap(ref list[k], ref list[i]); GetPermute(list, k + 1, m, actAddPermute); Swap(ref list[k], ref list[i]); } } }
voidSwap<T>(ref T a, ref T b) { T tmp; tmp = a; a = b; b = tmp; }