99乘法除法口诀各50个

Run Settings
LanguageRuby
Language Version
Run Command
#coding: GBK X_RANGE = (2..9) #第一个数的范围 Y_RANGE = (2..9) #第二个数的范围 MULT_FORMULA_CNTS = 50 #乘法算式总的个数 DIV_FORMULA_CNTS = 50 #除法算式总的个数 LINE_CNTS = 5 #每行算式个数 res = {} while res.size < MULT_FORMULA_CNTS do x = rand(X_RANGE) y = rand(Y_RANGE) if x != 1 && y != 1 key = sprintf("%d*%d", x, y) str = sprintf("%-2d × %-2d = ", x, y) res[key] = str end end while res.size < (MULT_FORMULA_CNTS + DIV_FORMULA_CNTS) do x = rand(X_RANGE) y = rand(Y_RANGE) if x != 1 && y != 1 key = sprintf("%d_%d", x, y) str = sprintf("%-2d ÷ %-2d = ", x*y, x) res[key] = str end end out_tab = res.to_a line = 0 out = {} out_size = 0 while out_size < 100 do i = rand(0..99) out[i] = i if out_size != out.size printf(out_tab[i][1]) line = line + 1 if line == LINE_CNTS puts "" puts "" line = 0 end out_size = out.size end end
Editor Settings
Theme
Key bindings
Full width
Lines