如题!比如我现在有2个数组,数组A比如有A,B,C, 数组B比如有a,b,c,d 想求高手给个算法把所有的组合都算出来。比如结果就该为Aa,Ab,Ac,Ad,Ba,Bb......
谢谢大家!

解决方案 »

  1.   

    for (int i = 0; i < A.Length; i++)
    {
       for(int j = 0; j < B.Length; j++)
       {
         Response.Write(A[i] + B[j] + ",");
       }
    }
      

  2.   

    string[] arr1 = {"A","B","C"};
    string[] arr2 = {"a","b","c","d"};
    string result = string.Empty;
    for(int i=0;i<arr1.Length;i++)
    {
    for(int j=0;j<arr2.Length;j++)
    {
    result += arr1[i] + arr2[j] + ",";
    }
    }
    result = result.TrimEnd(',');
    Response.Write(result);
      

  3.   

      string[] arrA = { "A", "B", "C" };
                string[] arrB = { "a", "b", "c", "d" };
                string result = string.Empty;
                for (int i = 0; i < arrA.Length; i++)
                {
                    for (int j = 0; j < arrB.Length; j++)
                    {
                        string A = arrA[i];
                        string B = arrB[j];
                        result = A + B;
                        Response.Write(result + "<br>");
                    }
                }
      

  4.   

    string a = "A,B,C";
            string b = "a,b,c,d";        string[] c = new string[a.Split(',').Length * b.Split(',').Length];
            int index = 0;
            for (int i = 0; i < a.Split(',').Length; i++)
            {
                for (int j = 0; j < b.Split(',').Length; j++)
                {
                    c[index] = a.Split(',')[i] + b.Split(',')[j];
                    Response.Write(a.Split(',')[i] + b.Split(',')[j]+"<br>");
                    index++;
                }
            }
      

  5.   

    string [] A = {"A","B","C"};
    string [] B = { "a", "b", "c", "d" };
    string[] C = new String[A.Length * B.Length];
    for (int i = 0; i < A.Length; i++)
    {
         for (int j = 0; j < B.Length; j++)
         {
               C[i*B.Length+j]=A[i]+B[j];
         }
    }
    for (int i = 0; i < C.Length; i++)
    {
         Console.WriteLine(C[i]);
    }