有人吗 帮忙想个小算法
比如输入123
就能获取1、2、3 的所有组合 123 132 321 等等
输入的个数是不固定的
请问要怎么写?
最主要的是 输入的 个数 不是固定的 ~~~~  谢谢各位了

解决方案 »

  1.   

    http://www.cnblogs.com/gpcuster/archive/2007/11/17/962848.html
      

  2.   

    我觉的每个输入的数可以用数组保存,用嵌套for循环判断应该是可以实现的
       可以借鉴冒泡程序
      

  3.   


            static void Main(string[] args)
            {
                Console.Write("please input a string:");
                string text = Console.ReadLine();
                Console.WriteLine("work out:");
                sf(text);
                Console.ReadKey();
            }        public static void sf(string str)
            {
                for (int i = 0; i < str.Length; i++)
                {
                    string a = str[0].ToString();
                    string b = str.Substring(1);
                    for (int j = 1; j < str.Length; j++)
                    {
                        str = b.Insert(j, a);
                        Console.WriteLine(str);
                    }
                }
            }这个也行,自己写的,参考冒泡
      

  4.   

    1:输入123,分别提取出来1,2,3,而不是12,3或者其他的,可以一个数字一个数字提取
    string s="123"; num[0]=s[0]-'0';...
    2.有了num数组之后就是全排列,我的blog有全排列的函数