共计 135 个字符,预计需要花费 1 分钟才能阅读完成。
require 'byebug'
as = 1..9
as.each do |a|
(1..a).each do |b|
a = a.to_i
b = b.to_i
#byebug
# s 用作对齐
s = a*b >= 10 ? "" :" "print" #{b} * #{a} = #{a*b}#{s}"
end
puts "\n"
end
正文完
共计 135 个字符,预计需要花费 1 分钟才能阅读完成。
require 'byebug'
as = 1..9
as.each do |a|
(1..a).each do |b|
a = a.to_i
b = b.to_i
#byebug
# s 用作对齐
s = a*b >= 10 ? "" :" "print" #{b} * #{a} = #{a*b}#{s}"
end
puts "\n"
end