別のカスタム値が与えられている配列を取り込もうとしています。私のベースがある場合たとえば、[2,3,1]
アレイは次のようになります。私は[2,3,1]
に着くときJavaでArrayListを使用してカスタム数を作成する
0,0,0
0,0,1
0,1,0
0,1,1
0,2,0
0,2,1
0,3,0
0,3,1
1,0,0 and so on...
ループが終了しなければなりません。私は自分のコードにいくつかの変更を加えましたので、以前よりも悪化する可能性があります。
max=0;
while (!(power.containsAll(listPot))){
while ((index<=listPot.get(pos))){ //Iterating the first digit
power.set(pos, index); //Updating the value
index++; //Increasing up to the limit found on listPot
}
index=0; //Reset the counter to put into the Array
if(max<limit){ //max would be the position of the next digit
max++;
}
if(power.get(max)<listPot.get(pos)){ //If next digit is < limit
index++; //move the index forward
power.set(max, index); //Increase the next digit
while (pos>=0){ //Removing the previous digits, like from 199 to 200
power.set(pos, 0);
pos--;
}
index=0;
}
else { //I increase max position again and proceed like above
pos=max;
max++;
while (pos>=0){ //Removing previous digits
power.set(pos, 0);
pos--;
}
index++; //Increasing the value to input
power.set(max, index);
}
index=0; //Reset the counters
pos=0;
}
メインループは配列が異なる間に繰り返します。私はすべてのゼロで同じ長さの新しいものを初期化しました。もう1つは対象のものです。
EDIT:私は配列の各位置でカスタム制限値を反復しようとしています。各サイクルで配列を使用して、与えられた数の除数で区切られた配列をロードします。私は、素因数を持つ配列と各要素の力を持つ配列をメソッドに提供します。
900の場合、素因数は[2,3,5]、電力は[2,2,2]になります。この特定のケースは、すべての要素が2であるためベース3の反復でなければなりません。これはすべてのケースで可能ではないため、より柔軟な処理をしようとしています。
私は配列の次の位置に移動するときに来るので、数値から得た値を適切にループするための変数の使い方についてのヘルプを探しています。
あなたが達成しようとしていることを教えてくださいできますか?あなたの質問は理解しにくいです –
あなたの質問は何ですか? –
私はそれを得ることができません:あなたが構築しようとしているアレイは何ですか? –