我被困在这个问题上了。我尝试用 Ruby 解决它。
我的答案是
4.times{|i| puts "#{i}"} && 5.upon(7){|i| puts "#{i}}
但是,我不确定它是否正确。
最佳答案
这应该适合你
result = (0..3).to_a.product((5..7).to_a)
puts result.inspect
#=> [[0, 5], [0, 6], [0, 7], [1, 5], [1, 6], [1, 7], [2, 5], [2, 6], [2, 7], [3, 5], [3, 6], [3, 7]]
关于 ruby 编码 : Sequence of number pairs "x,y" such that x ranges from 0 to 3 and y from 5 to 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13486739/