当前位置:网站首页>姑姑:给小学生出点口算题
姑姑:给小学生出点口算题
2022-08-02 19:23:00 【lonelyMangoo】
姑姑带着妹妹来我家玩,让我给孩子出点口算题,我当仁不让,直接出了1000题给妹妹做。
效果如下,内容存在了txt中。

下面是代码,只需要改几个变量就能改出题的量和难度。
/** * @version 1.0 * @author: Pig One * @date: 2022/8/1 10:46 * @decription: 出几条10以内的加减法给孩子做做 */
public class Arg_10 {
//做10以内的加减法,两个加起来不超过十
final static int MAX_SUM = 10;
//一天昨天20道题题
final static int DAY_TASKS = 20;
//一共多少天的量
final static int DAYS = 50;
public static void main(String[] args) {
try {
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("/Users/zhuyi/IdeaProjects/Spirng5Learn/demo01/src/com/zy/LCSummer/task.txt")));
BufferedWriter writerRes = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("/Users/zhuyi/IdeaProjects/Spirng5Learn/demo01/src/com/zy/LCSummer/res.txt")));
for (int i = 0; i < DAY_TASKS * DAYS; i++) {
int a = new Random().nextInt(MAX_SUM);
int b = new Random().nextInt(MAX_SUM);
//两数之和大于10且不为0
while ((a + b) > MAX_SUM || a == 0 || b == 0) {
a = new Random().nextInt(MAX_SUM);
b = new Random().nextInt(MAX_SUM);
}
if (i == 0) {
writer.write("口算 1000题");
writerRes.write("口算 1000题 答案");
}
if (i % DAY_TASKS == 0) {
writer.write("\n\n");
writerRes.write("\n\n");
writer.write("day " + (i / DAY_TASKS + 1));
writerRes.write("day " + (i / DAY_TASKS + 1) + " answer");
writer.newLine();
writerRes.newLine();
}
String task = (i % DAY_TASKS + 1) + ": " + a + " + " + b + " = ? ";
String res = (i % DAY_TASKS + 1) + ": " + (a + b);
writer.write(task);
writer.newLine();
writerRes.write(res);
writerRes.newLine();
}
// System.out.println(a+ "+" +b +"=?");
writer.flush();
writer.close();
writerRes.flush();
writerRes.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
快去折磨孩子吧!
对了,如果有小数,需要加一点判断把a、b变成浮点数。
妹妹:听我说谢谢你。
边栏推荐
猜你喜欢

JVM内存和垃圾回收-05.虚拟机栈

平稳发展 | 西欧地区手游玩家的数据和洞察

简单有效又有用的关闭antimalware service executable的方法·备份记录

实现客户服务自助,打造产品知识库

【Psychology · Characters】Issue 1

Detailed explanation of common examples of dynamic programming

LeetCode:622. 设计循环队列【模拟循环队列】

牛客题目——滑动窗口的最大值、矩阵最长递增路径、顺时针旋转矩阵、接雨水问题

MySQL安装(详细,适合小白)

扫码预约 | 观看Apache Linkis数据处理实践以及计算治理能力
随机推荐
动态折线图,制作原来是这么简单
Mysql安装流程 【压缩版】
Dynamically generate different types of orders, how do I deposit to mongo database?
golang刷leetcode 经典(10) tire树与ac自动机
Detailed explanation of common examples of dynamic programming
golang刷leetcode 数学(1) 丑数系列
【C语言刷题】双指针原地修改数组(力扣原题分析)
竞赛:糖尿病遗传风险检测挑战赛(科大讯飞)
「面试必会」这应该是最有深度的TCP三次握手、四次挥手细节讲解
松鼠短视频系统为用户加入随机头像代码-快速为用户加上随机头衔
线程池原理与实践|从入门到放弃,深度解析
SQL-UDT是什么功能?
银保监会:人身险产品信披材料应由保险公司总公司统一负责管理
一款好用的FAQ搭建工具
ShapeableImageView 的使用,告别shape、三方库
What is a Field Service Management System (FSM)?what is the benefit?
Flutter自带国际化适配自动生成方案
openlayers版本更新差别
服务器Centos7 静默安装Oracle Database 12.2
【LeetCode】1161. 最大层内元素和