1. Requirements Analysis:
Java or C language used to complete a calculation program automatically generates four questions in order to simplify the calculation process, to improve efficiency.
2. Functional Design
(1) automatically generates four arithmetic operation of Equation 2 number less than 10 100 (+ - * /), operation results are required within 100
(2) discarding duplicates equation. = 2 + 3 + 3 = 2 and Equation 2 is repeated and 3 + = 3 + 2 = not repeated formula
Number (3) title can be customized
(4) parameters can be controlled
Whether to include multiplication and division
Controllable range values of the operands (e.g., operands within 100 or within 1000)
Whether operands containing negative
(5) generating operation to an external file title stored in result.txt
3. Design and Implementation
With the c programming language, the c-free main function implemented by
4. Run the test
5. Insert Code
1 main() 2 { 3 4 int rand_1,rand_2,rand_3,i; 5 int rand_4,store=0; 6 int number,temp,number_1; 7 srand((unsigned)time(NULL));//生成随机种子 8 printf("请输入您要生成题目的数量\n"); 9 scanf("%d",&number);//定义输入控制循环变量 10 printf("0 代表加减乘除随机生成\n1 代表加\n2 代表减\n3 代表乘\n4 代表除\n"); 11 scanf("%d",&temp);//选项 12 number_1=number; 13 while(number>=1) 14 { 15 16 switch(temp)//选项内容 17 { 18 case 0: number--;break;//退出循环 19 20 21 case 1: rand_1= rand()%100; //随机种子 22 rand_2= rand()%100; 23 rand_3=rand_1+rand_2;//运算 24 if(rand_3<1000) 25 number--;//计次 26 else 27 break; 28 printf("%d+%d=%d\n",rand_1,rand_2,rand_3); 29 number_1=0; 30 break;//退出循环 31 32 case 2: rand_1= rand()%100; 33 rand_2= rand()%100; 34 rand_3=rand_1-rand_2; 35 if(rand_3<1000) 36 number--; 37 else 38 break; 39 printf("%d-%d=%d\n",rand_1,rand_2,rand_3); 40 number_1=0; 41 break;
1 if(number_1>=1)//查看时候进行上面的算法满足则进行 2 { 3 4 5 while(1)//死循环 6 { 7 rand_4=rand()%100; 8 rand_4=rand_4/10;//生成随机数 9 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 10 if(rand_4>=0&&rand_4<=3)//产生随机选择四个运算 11 { 12 13 switch(rand_4) 14 { 15 case 0: 16 rand_1= rand()%100; //此处同上 17 rand_2= rand()%100; 18 rand_3=rand_1+rand_2; 19 if(rand_3<1000) 20 store++; 21 else 22 break; 23 printf("%d+%d=%d\n",rand_1,rand_2,rand_3); 24 break;
6.总结
程序编写的不太完善,也有好多不懂得地方,以后多加改正,认真学习。
7.PSP
PSP2.1 |
任务内容 |
计划共完成需要的时间(min) |
实际完成需要的时间(min) |
Planning |
计划 |
20 |
20 |
Estimate |
· 估计这个任务需要多少时间,并规划大致工作步骤 |
30 |
40 |
Development |
开发 |
110 |
150 |
Analysis |
需求分析 (包括学习新技术) |
10 |
15 |
Design Spec |
· 生成设计文档 |
10 |
15 |
Design Review |
· 设计复审 (和同事审核设计文档) |
10 |
15 |
Coding Standard |
代码规范 (为目前的开发制定合适的规范) |
10 |
15 |
Design |
具体设计 |
20 |
30 |
Coding |
具体编码 |
60 |
120 |
Code Review |
· 代码复审 |
10 |
15 |
Test |
· 测试(自我测试,修改代码,提交修改) |
15 |
30 |
Reporting |
报告 |
20 |
30 |
Test Report |
·总结改进 |
10 |
20 |