puts '九九乘法表:' (1..9).each{|i| (1..i).each{|j| p = i*j print j.to_s + '*' + i.to_s + '=' if p.to_s.length==1 then print p.to_s + ' ' else print p.to_s + ' ' end } puts '' }
x = ['','一','二','三','四','五','六','七','八','九'] y = [0,1,2,3,4,5,6,7,8,9] y.each{|i| (1..i).each{|j| p = i*j print x[j].to_s + '' + x[i].to_s if p.to_s.length==1 then print '得' + p.to_s + ' ' else print p.to_s + ' ' end } puts '' }