`

ruyb 数组转换二维数组

    博客分类:
  • ruby
 
阅读更多
array = [1,3,6,4,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,5,3,3,5,6,5,4,4,6,9]
p size = array.length
s_size = 0
if size%8 == 0
    s_size=size/8
else
    s_size=size/8+1
end
p s_size,"**"
sa = []
i = 1
s_size.times{    
    p array[8*(i-1)..(8*i-1)]
    sa << array[8*(i-1)..(8*i-1)]
    i += 1
}
p sa

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics