如题

解决方案 »

  1.   

    http://topic.csdn.net/u/20090217/21/f41ed9f6-f929-451c-a5c9-80d2e408422a.html?56197
      

  2.   

    以前为了追求效率都是自己模拟栈,现在还是化繁为简,直接用递归了,代码简单
    using System;namespace ConsoleApplication4
    {
        class Program
        {
            static string[] Items = new string[] { "A", "B", "C", "D", "E" };        static void Main(string[] args)
            {
                int selectCount = 2;
                Select(0, selectCount, string.Empty);
            }        static void Select(int currentIndex, int remain, string currentSelect)
            {
                if (remain == 0)
                {
                    Console.WriteLine(currentSelect);
                    return;
                }            if (Items.Length - currentIndex < remain)
                    return;            Select(currentIndex + 1, remain - 1, currentSelect + Items[currentIndex]);
                Select(currentIndex + 1, remain, currentSelect);
            }
        }
    }