From 75f032d79023fcf40dc8a52ebb2b3dc190aad609 Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 22 Jun 2021 22:54:20 +0800 Subject: *divide --- Assets/Test/05_Recursion/Test_Recursion.cs | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'Assets/Test/05_Recursion/Test_Recursion.cs') 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 data = new List { 'a', 'b', 'c' }; - //int count = 0; - //foreach (List 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 data = new List { 'a', 'b', 'c' , 'd'}; + List data = new List { 'a', 'b', 'c' }; int count = 0; + foreach (List 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> perms = new List>(); RecursionHelper.Permutations(data, ref perms); foreach (List p in perms) -- cgit v1.1-26-g67d0