summaryrefslogtreecommitdiff
path: root/Assets/Test/05_Recursion
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/Test/05_Recursion')
-rw-r--r--Assets/Test/05_Recursion/Test_Recursion.cs25
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)