日期:2009-12-29  浏览次数:20379 次

C#以非递归方式实现三位排列组合,如下代码:

  1. //深度优先 
  2. class Program 
  3.     { 
  4.         static void Main(string[] args) 
  5.         { 
  6.             int[] number = new int[] { 1, 3, 5, 7 }; 
  7.             List data = new  List(); 
  8.             Stack openStack = new Stack(); 
  9.             Tree root = new Tree(); 
  10.             Tree parent =root; 
  11.             while (true
  12.             { 
  13.  
  14.                 if (parent.GetDeep() == 4) 
  15.                 { 
  16.                     parent.printf(); 
  17.  
  18.                 } 
  19.                 else 
  20.                 { 
  21.                    var tempSon= number.ToList(); 
  22.                    foreach (var item in tempSon) 
  23.                    { 
  24.                        Tree Node = new Tree(); 
  25.               &nbs