万金流
初次使用博客园,目前感觉还不错。 不知不觉用了4年零4个月了,越来越喜欢博客园。

偷懒,c#代码:

class Program
    {
        static char[] c = new char[6];
        static int l;
        static void Main(string[] args)
        {
            string s;
            s = Console.ReadLine();
            l = s.Length;
            qiongju(0, s);
            Console.ReadKey();
        }
        static void qiongju(int p,string s)
        {
            if (p == l)
            {
                for (int i = 0; i < l; i++)
                {
                    Console.Write(c[i]);
                }
                Console.WriteLine();
            }
            else
            {
                for (int i = 0; i < s.Length; i++)
                {
                    c[p] = s[i];
                    qiongju(p + 1, s.Remove(i, 1));
                }
            }
        }
    }

运行结果:

 

posted on 2020-07-13 17:20  万金流  阅读(313)  评论(0编辑  收藏  举报