日期:2009-12-29 浏览次数:20410 次
C#以非递归方式实现三位排列组合,如下代码:
- //深度优先
- class Program
- {
- static void Main(string[] args)
- {
- int[] number = new int[] { 1, 3, 5, 7 };
- List data = new List();
- Stack openStack = new Stack();
- Tree root = new Tree();
- Tree parent =root;
- while (true)
- {
- if (parent.GetDeep() == 4)
- {
- parent.printf();
- }
- else
- {
- var tempSon= number.ToList();
- foreach (var item in tempSon)
- {
- Tree Node = new Tree();
- &nbs