0
私は好き..マトリックス中のすべての可能な0の組み合わせと1を生成する必要があります。 1024X 10マトリックスにおける0の組み合わせと1を生成する方法
0000000000, 0000000001, 0000000010, 0000000011.... etc.
がそれを行うには良い方法があります以下に示すようにネストされたforループを使用するのではなく?
class Reliability {
// Trying to create combinations of 0 and 1s
public static void main(String[] args) {
// Creating an array of size 1024X10
int connectMat[][] = new int[1024][10];
int count1 = 0;
// Intitially all rows are set to zero
for (int r1 = 0; r1 <= 1; r1++) {
// fill all rows with 0 and the 1
for (int r2 = 0; r2 <= 1; r2++) {
for (int r3 = 0; r3 <= 1; r3++) {
for (int r4 = 0; r4 <= 1; r4++) {
// Updating the elements of each row
connectMat[count1][0] = r1;
connectMat[count1][1] = r2;
connectMat[count1][2] = r3;
connectMat[count1][3] = r4;
// Incrementing count to point to the next row
count1++;
}
}
}
}
"コンビネーション"とは何でしょうか? – Mordechai
組み合わせを「見つけよ」または「生成する」必要がありますか? - 「組み合わせ」という言葉の意味は何ですか? – Mordechai
私は組み合わせを生成する必要があります – Connors