20194585- automatically generates four arithmetic problem first edition report

1. Demand Analysis

  • 1 randomly generates four arithmetic operation, the same problem does not occur
  • 2. Within the range of 100
  • 3. Provide the number of users choice of window
  • 4. The user-selectable multiplication and division windows
  • 5. The resulting equation is stored in the designated location of the title

2. Functional Design

  • basic skills

       - 自动生成10道100以内的2个操作数的四则运算算式(+ - *  /),运算结果也在100以内
    
       - 剔除重复算式。 
    
       - 题目数量可定制
    
       - 相关参数可控制
    
                - 是否包含乘法和除法
    
                - 操作数数值范围可控(如操作数 在100以内   还是1000以内)
    
                - 操作数是否含负数    
    
         - 生成的运算题存储到外部文件result.txt中
  • Expansion capabilities

3. Design and Implementation

  • First create a menu implemented c language control loop for the number of items randomly generated by the operator using a switch statement

4. Test Run

5. Paste the code

···

for(k=0;k<b;k++)
      {
    i=rand()%a;//生成一个0-99之间的随机数
    j=rand()%a;//生成一个0-99之间的随机数
    q=rand()%4 ;//生成一个0-3之间的随机数来代表运算符号 
         printf("%d", i);
     switch(q)
    {
        case 0:
        printf("+");
            c='+';
            result=i+j;
            break;
            case 1:
            printf("-");
            c='-';
            result=i-j;
            break;
            case 2:
            printf("*");
            c='*';
            result=i*j;
            break;
            case 3:
            printf("/");
            c='/';
            result=i/j;
            break;
            default:
            printf("wrong");
          }
          printf("%d=\n",j);
         
          fprintf(fp,"%d %c %d\r\n",i,c,j,i);
      }

···

6. Summary

  • By the completion of the job, he still found many deficiencies, had learned something did not come smoothly applications, including the preparation of the code more difficult to throw long, we wanted to enhance learning, multi-compile.

7.PSP

SUMMARY Plans to use the time (h) The actual use of time (h)
plan 7 9
· Plan total time needed 7 8.5
Develop 5.1 7.2
· Design Review 0.2 0.1
·demand analysis 0.1 0.2
· Code Specification 0.1 0.2
· Specific design 0.2 0.2
· Specific coding 3 5
· Code Review 1 0.5
·test 0.5 1
report 1.2 1.2
·testing report 0.5 0.5
· Computing workload 0.2 0.2
· Later reports 0.5 0.5

Guess you like

Origin www.cnblogs.com/cxj123456/p/11529012.html