题解 | #字符串分隔#
字符串分隔
http://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
str = STDIN.gets.strip
t = str.size % 8 == 0 ? 0 : 8 - (str.size % 8)
str = str + ('0' * t)
(str.size / 8).times do |i|
p = i * 8
puts str[p..(p+7)]
end
字符串分隔
http://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
str = STDIN.gets.strip
t = str.size % 8 == 0 ? 0 : 8 - (str.size % 8)
str = str + ('0' * t)
(str.size / 8).times do |i|
p = i * 8
puts str[p..(p+7)]
end
相关推荐