First, the needs analysis
通过该程序的设计,减轻老师和家长的出题负担。
Second, the functional design
1.自动生成可定制道100以内的2个操作数的四则运算算式(+ - * /),要求运算结果也在100以内
2.题目数量可自定义
3.操作数数值范围可自定义(100以内)
4.其他: (1).是否包含乘法和除法
(2).操作数是否含负数
(3).生成的运算题存储到外部文件result.txt中
Third, the design and implementation
using c language design and implementation.
Fourth, the test run
V. snippet
1 comprising determining whether the sign.
printf("请输入是否带负号:"); //1带0不带
scanf("%d",&g);
for(i=0;i<n;i++){
if(g==0){
a=rand()%z;
b=rand()%z; //随机生成两个正数
}else if(g==1){
a=rand()%z*(rand()%100>0.5?1:-1);
b=rand()%z*(rand()%100>0.5?1:-1); //随机生成两个正或负数
}
2. randomly generated symbols output.
c=rand()%4; //生成0-3随机数
switch(c)
{
case 0:sum=a+b;f='+';
if(a+b<=100){
printf("%d+%d=",a,b);
printf("\n");
}
break;
case 1:sum=a*b;f='*';
if(cc==1){
if(a*b<=100){
printf("%d*%d=",a,b);
printf("\n"); //cc=1时包含乘法
}
}else if(cc==0){
i--;
continue;
}break; //cc=0时不包含乘法,for处重新执行
case 2:sum=a-b;f='-';
printf("%d-%d=",a,b);
printf("\n");
break;
case 3:sum=a/b;f='/';
if(cc==1){
printf("%d/%d=",a,b); //cc=1时包含乘法
}
else if(cc==0){
i--;
continue; //cc=0时不包含除法,for处重新执行
}
printf("\n");
break;
}
VI Summary
Some places may not be perfect, but it is also painstakingly written out ... hope in the future to continue learning to enhance their professional skills and improved.
Seven, PSP
psp2.1 | SUMMARY | Plan time (min) required to complete a total of | The actual time required for completion (min) |
Planning | plan | 15 | 20 |
· Estimate | It estimated that the task requires much time and planning generally work steps | 10 | 10 |
Development | Develop | 150 | 185 |
·· Analysis | Needs analysis (including learning new technologies) | 10 | 20 |
· Design Spec | Generate design documents | 15 | 30 |
· Coding Standard | · Code specifications (development of appropriate norms for the current development) | 10 | 25 |
·Coding | · Specific coding | 150 | 220 |
·Code Review | · Code Review | 10 | 25 |
·Test | · Test (self-test, modify the code, submit modifications) | 15 | 18 |
·Reporting | · Report | 10 | 40 |
· Test Report | · · testing report | 10 | 15 |
· Size Measurement | · Computing workload | 10 | 10 |
· Postmortem & Process Improvement Plan | · Hindsight, and propose process improvement plan | 15 | 15 |