そもそもbit全探索って何
ぐぐると山ほど見つかります。。。
自作のコード(Java)
public class Main {
public static void main(String[] args) {
// 「2の5乗」回ループ
for (int i = 0; i < (1 << 5); i++) {
// 5回ループ
for (int j = 0; j < 5; j++) {
if ((1 & i >> j) == 1) {
System.out.print("o");
} else {
System.out.print("x");
}
}
System.out.println(" " + i);
}
}
}
上記コードの実行結果
xxxxx 0
oxxxx 1
xoxxx 2
ooxxx 3
xxoxx 4
oxoxx 5
xooxx 6
oooxx 7
xxxox 8
oxxox 9
xoxox 10
ooxox 11
xxoox 12
oxoox 13
xooox 14
oooox 15
xxxxo 16
oxxxo 17
xoxxo 18
ooxxo 19
xxoxo 20
oxoxo 21
xooxo 22
oooxo 23
xxxoo 24
oxxoo 25
xoxoo 26
ooxoo 27
xxooo 28
oxooo 29
xoooo 30
ooooo 31
おしまい。