跟小D每日学口语

输出一个字符串的所有排列组合,有重复字符

        static void Main(string[] args)
        {
            string str2 = "";
            Method("1234", str2);
            Console.WriteLine(counter);
            Console.ReadKey();
        }

        static void Method(string str,string str2)
        {
            if (str == null)
                return;

            if (str == string.Empty)
            {
               Console.WriteLine(str2);
               counter++;
              
            }

            for (int i = 0; i < str.Length; i++)
            {
                Method(str.Remove(i, 1), str2+str[i].ToString());
            }
        }


posted @ 2010-08-04 17:41  简简单单幸福  阅读(3641)  评论(0编辑  收藏  举报