当前位置:网站首页>姑姑:给小学生出点口算题
姑姑:给小学生出点口算题
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变成浮点数。
妹妹:听我说谢谢你。
边栏推荐
- 栈、队列和数组
- SQL server有什么认证吗?
- E - Addition and Multiplication 2(贪心)
- 快速掌握jmeter(一)——实现自动登录与动态变量
- 分享一个 web 应用版本监测 (更新) 的工具库
- LeetCode - 105. 从前序与中序遍历序列构造二叉树;023.合并K个升序链表
- Geoserver+mysql+openlayers
- 松鼠短视频系统为用户加入随机头像代码-快速为用户加上随机头衔
- 如何获取EasyCVR平台设备通道的RTMP视频流地址?
- What is a Field Service Management System (FSM)?what is the benefit?
猜你喜欢
随机推荐
译出我精彩 | 7月墨力翻译计划获奖名单公布
Golang sync/atomic 包的原子操作说明
geoserver+mysql+openlayers问题点
LeetCode:622. 设计循环队列【模拟循环队列】
我靠这套笔记自学,拿下字节50万offer....
Brain-computer interface 003 | Musk said that he has realized a virtual self-dialogue with the cloud, and related concept shares have risen sharply
NC | Structure and function of soil microbiome reveal N2O release from global wetlands
Metaverse 001 | Can't control your emotions?The Metaverse is here to help you
AI科学家:自动发现物理系统的隐藏状态变量
JVM内存和垃圾回收-06.本地方法栈
【C语言刷题】双指针原地修改数组(力扣原题分析)
Introduction of uncommon interfaces of openlayers
Cannot find declaration to go to
MaxCompute 的SQL 引擎参数化视图具体有哪些增强功能?
分布式事务
7.21 - 每日一题 - 408
Three.js入门
软考 ----- UML设计与分析(下)
What is the use of IT assets management software
当TIME_WAIT状态的TCP正常挥手,收到SYN后…