parent
7da75961a4
commit
132bdded9d
@ -0,0 +1,8 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="openjdk-24" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/math_exam_generator2.iml" filepath="$PROJECT_DIR$/math_exam_generator2.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
Binary file not shown.
@ -0,0 +1,2 @@
|
||||
public interface Info {
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,41 @@
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* 小学题目生成器实现
|
||||
* 生成适合小学生的数学题目
|
||||
*/
|
||||
public class PrimaryQuestionGenerator implements QuestionGenerator {
|
||||
@Override
|
||||
public String generateQuestion(StringBuilder question, Random random) {
|
||||
int num1 = random.nextInt(100) + 1; // 1-100的随机数
|
||||
int num2 = random.nextInt(100) + 1;
|
||||
String[] operators = {"+", "-", "*", "/"};
|
||||
String op = operators[random.nextInt(operators.length)];
|
||||
|
||||
// 确保减法和除法结果为正整数
|
||||
if ("-".equals(op) && num1 < num2) {
|
||||
int temp = num1;
|
||||
num1 = num2;
|
||||
num2 = temp;
|
||||
} else if ("/".equals(op)) {
|
||||
// 确保除法结果为整数
|
||||
num1 = num2 * (random.nextInt(10) + 1);
|
||||
}
|
||||
|
||||
// 10%的概率添加括号
|
||||
if (random.nextDouble() < 0.1) {
|
||||
question.append("(");
|
||||
question.append(num1);
|
||||
question.append(" ").append(op).append(" ");
|
||||
question.append(num2);
|
||||
question.append(")");
|
||||
} else {
|
||||
question.append(num1);
|
||||
question.append(" ").append(op).append(" ");
|
||||
question.append(num2);
|
||||
}
|
||||
|
||||
question.append(" = ?");
|
||||
return question.toString();
|
||||
}
|
||||
}
|
Binary file not shown.
@ -0,0 +1,15 @@
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* 题目生成器接口
|
||||
* 定义生成数学题目的基本方法
|
||||
*/
|
||||
public interface QuestionGenerator {
|
||||
/**
|
||||
* 生成一道数学题目
|
||||
* @param question 用于构建题目的StringBuilder
|
||||
* @param random 随机数生成器
|
||||
* @return 生成的题目字符串
|
||||
*/
|
||||
String generateQuestion(StringBuilder question, Random random);
|
||||
}
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,39 @@
|
||||
1. 1 * 34 = ?
|
||||
|
||||
2. 30 + 93 = ?
|
||||
|
||||
3. 82 * 33 = ?
|
||||
|
||||
4. 98 * 97 = ?
|
||||
|
||||
5. 58 * 77 = ?
|
||||
|
||||
6. 97 - 96 = ?
|
||||
|
||||
7. 86 - 27 = ?
|
||||
|
||||
8. 73 - 22 = ?
|
||||
|
||||
9. 52 + 5 = ?
|
||||
|
||||
10. 42 - 6 = ?
|
||||
|
||||
11. 72 * 62 = ?
|
||||
|
||||
12. 60 - 23 = ?
|
||||
|
||||
13. 43 - 37 = ?
|
||||
|
||||
14. 198 / 99 = ?
|
||||
|
||||
15. 4 / 1 = ?
|
||||
|
||||
16. 42 + 57 = ?
|
||||
|
||||
17. 356 / 89 = ?
|
||||
|
||||
18. 144 / 36 = ?
|
||||
|
||||
19. 189 / 21 = ?
|
||||
|
||||
20. 74 + 43 = ?
|
Loading…
Reference in new issue