在尝试迭代字母数组并生成所有 6 个字符(仅限 alpha)字符串时,我的迭代似乎在最内部嵌套循环的单个 while 循环之后结束。代码如下。想法?
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
x1 = 0
x2 = 0
x3 = 0
x4 = 0
x5 = 0
x6 = 0
while x1<26
y1 = alpha[x1]
while x2<26
y2 = alpha[x2]
while x3<26
y3 = alpha[x3]
while x4<26
y4 = alpha[x4]
while x5<26
y5 = alpha[x5]
while x6<26
y6 = alpha[x6]
puts y1 + y2 + y3 + y4 + y5 + y6
x6 = x6 + 1
end
x5 = x5 + 1
end
x4 = x4 + 1
end
x3 = x3 + 1
end
x2 = x2 + 1
end
x1 = x1 + 1
end
编辑:我也很可能忽略了一种更简单的方法来实现预期的结果。如果是这样,请随时纠正我。