func output(num: Int) {
for n in (0 ..< Int(pow(2.0, Double(num)))) {
var d = [Int]()
for m in (0 ..< num) {
if n / Int(pow(2.0, Double(m))) % 2 == 0 {
d.append(0)
} else {
d.append(1)
}
}
Swift.print(d)
}
}
num=4の時の出力結果
[0, 0, 0, 0]
[1, 0, 0, 0]
[0, 1, 0, 0]
[1, 1, 0, 0]
[0, 0, 1, 0]
[1, 0, 1, 0]
[0, 1, 1, 0]
[1, 1, 1, 0]
[0, 0, 0, 1]
[1, 0, 0, 1]
[0, 1, 0, 1]
[1, 1, 0, 1]
[0, 0, 1, 1]
[1, 0, 1, 1]
[0, 1, 1, 1]
[1, 1, 1, 1]