diff options
author | chai <chaifix@163.com> | 2021-06-22 22:54:20 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-06-22 22:54:20 +0800 |
commit | 75f032d79023fcf40dc8a52ebb2b3dc190aad609 (patch) | |
tree | 9e03067ef42dceb3f90e3988f6e027bc035b7429 /Assets/Test/05_Recursion | |
parent | 8938c3447d88e31f77f20553ed185fc8e64c9ac8 (diff) |
*divide
Diffstat (limited to 'Assets/Test/05_Recursion')
-rw-r--r-- | Assets/Test/05_Recursion/Test_Recursion.cs | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/Assets/Test/05_Recursion/Test_Recursion.cs b/Assets/Test/05_Recursion/Test_Recursion.cs index 7529270..aef587c 100644 --- a/Assets/Test/05_Recursion/Test_Recursion.cs +++ b/Assets/Test/05_Recursion/Test_Recursion.cs @@ -21,21 +21,20 @@ public class Test_Recursion : MonoBehaviour void TestPermutations()
{
// 全排列
- //Debug.Log("全排列");
- //List<char> data = new List<char> { 'a', 'b', 'c' };
- //int count = 0;
- //foreach (List<char> p in RecursionHelper.Permutations(data))
- //{
- // count++;
- // string content = "";
- // p.ForEach((char c) => content += c + " ");
- // Debug.Log(content);
- //}
- //Debug.Assert(count == Algorithms.Factorial(data.Count));
-
Debug.Log("全排列");
- List<char> data = new List<char> { 'a', 'b', 'c' , 'd'};
+ List<char> data = new List<char> { 'a', 'b', 'c' };
int count = 0;
+ foreach (List<char> p in RecursionHelper.Permutations(data))
+ {
+ count++;
+ string content = "";
+ p.ForEach((char c) => content += c + " ");
+ Debug.Log(content);
+ }
+ Debug.Assert(count == Algorithms.Factorial(data.Count));
+
+ Debug.Log("全排列");
+ count = 0;
List<List<char>> perms = new List<List<char>>();
RecursionHelper.Permutations(data, ref perms);
foreach (List<char> p in perms)
|