2

やあみんな、私はこのようなものを持っています:

  String keyBase = "keyA";
  String[] valueBase = {"a1","a2","a3"};

  String keyLevel1 = "keyB";
  String[] valueLevel1 = {"b1","b2","b3"};

  String keyLevel2 = "keyC";
  String[] valueLevel2 = {"c1","c2","c3"};

そして、このようなものが必要です:

String[][] f1 = {{"keyA","a1"},{"keyB","b1"}{"keyC","c1"}}
String[][] f2 = {{"keyA","a1"},{"keyB","b1"}{"keyC","c2"}}
String[][] f2 = {{"keyA","a1"},{"keyB","b1"}{"keyC","c3"}}

String[][] f5 = {{"keyA","a1"},{"keyB","b2"}{"keyC","c1"}}
String[][] f6 = {{"keyA","a1"},{"keyB","b2"}{"keyC","c2"}}
...

これを行うための簡単ですが良い方法は何ですか?

ありがとう

4

1 に答える 1

0

再帰順列についてはわかりません。
私はあなたの出力に基づいて試しました。

for(int i = 0 ; i <3 ; i++) {
   for(int j = 0 ; j <3 ; j++) {
      for(int k = 0 ; k <3 ; k++) {
         system.out.println(keyBase +","+ valueBase[i] +","+
                            keyLevel1  +","+ valueLevel1[j]  +","+
                            keyLevel2  +","+ valueLevel2[k] )
      }
   }
 }
于 2013-02-08T05:31:12.690 に答える