String WM[][] = new String[][8], WM矩阵的列数是确定的,要求每一次从每一个列中取一个元素,组成一个8个元素的数组进行某个操作,也就是说,每一次操做都在WM的第一列选一个元素,然后在第二列选一个元素,.......第八列选一个元素,组成8个元素的数组。要求对矩阵中所有的可能组合都进行这样的操作。请问这个算法怎样写啊?我想了好久都没有想到!!!

解决方案 »

  1.   

    http://community.csdn.net/Expert/topic/4857/4857766.xml?temp=.6773035
    看卡西C的回复
      

  2.   

    public void fun(int colcount,string a)//colcount表示列数
        {
            if (colcount < 8)
            {
                for (int i = 0; i <= colcount; i++)
                {
                    System.Out.print(a[i][colcount]);//将第i行colcount列的数组元素打印出来
                    fun(colcount + 1, a);
                }
            }
        }
    main()
    {
     string[,] a = new string[n, 8];
            fun(0, a);
    }
      

  3.   

    当colcount>8时表示已经达到最后一列不用在递归