knowyourtables.groovy

来自「Groovy动态语言 运行在JVM中的动态语言 可以方便的处理业务逻辑变化大的业」· GROOVY 代码 · 共 17 行

GROOVY
17
字号
/** 
 * Simple mathematics quiz
 * @author: Jeremy Rayner
 * based on algorithms from INPUT/Marshall Cavendish/1984
 */
while (true) {
    try {
        def n = (int)(Math.random() * 12) + 1
        println "What is $n times 9?"
        def a = System.in.readLine().toInteger()
        if (a == n * 9) println "Correct"
              
    } catch (Exception e) {
        println "The computer didn't understand your input"
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?