小学二年级乘法口诀练习题2,类似4× =28, ×6=12

小学二年级乘法口诀练习题2,类似4× =28, ×6=12, ×2=4,6× =48,6× =42

代码:

public class practice03 {
    public static void main(String[] args) {
        Random rand = new Random(); //生成随机数
        int i = 0;  //控制循环次数
        while (i < 100) {
            //rand.nextInt(MAX - MIN + 1) + MIN;
            int num1 = rand.nextInt(7) + 2; //生成2~9的随机数
            String blank = "  ";    //空格
            int result = rand.nextInt(79) + 2;  //两数相乘的结果在2~81
            int remainder = result % num1; //余数
            int quotient = result / num1;  //商

            //商不能等于0和1(不等于1是想着提高难度),余数要等于0
            if (remainder != 0 || quotient >= 10 || quotient == 1)
                continue;

            //交叉生成两张题目
            if (i % 2 == 1 && num1 >= quotient) {
                System.out.println(blank + "×" + num1 + "=" + result);
            } else if (i % 2 == 0 && num1 >= quotient) {
                System.out.println(quotient + "×" + blank + "=" + result);
            }
            i++;
        }
    }
}

打印结果如下:

6×  =42
  ×3=9
  ×7=14
  ×5=25
2×  =4
  ×6=36
4×  =32
  ×7=35
  ×6=18
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值