作业三:代码复审

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了作业三:代码复审相关的知识,希望对你有一定的参考价值。

   我审查的刘彦麟同学的代码,我已经用CFREE运行,可以成功运行也发符合条件。并且每一行代码都很清晰,可以很清晰的看出每一行代码的意义,有很好的规范性,在复查过程中,我也学习了很多,包括对代码的规范性。我觉得代码复查时件很有用,很能学东西的事情!

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int add(int num1,int num2)
{
 return num1+num2;
}
int subtraction(int num1,int num2)
{
 return num1-num2;
}
int mul(int num1,int num2)
{
 return num1*num2;
}
float divis(int num1,int num2)
{
 return ((int)(((float)num1/num2)*100+0.5))/100.0;
}
int main()
{ 
 int type = -1;
 int data = -1;
 int choice,num1,num2,results;
 float div_result;
 char ch;
 int i,j,num3,num4; 
 printf("请输入四则运算题目的数量:\n");
 scanf("%d",&j); 
 srand((unsigned int)time(NULL));
 for(i=0;i<j;i++){
     num3=rand()%100+1;
     num4=rand()%100+1;
       choice=rand()%8;
  switch (choice)
  {
  case 1:
    num1 = rand()%100+1;
    num2 = rand()%100+1;
    printf("%d+%d=\n",num1,num2);
   break;
  case 2:
    num1 = rand()%100+1;
    num2 = rand()%100+1;
    printf("%d-%d=\n",num1,num2);
   break;
  case 3:
    num1 = rand()%10;
    num2 = rand()%10;
    printf("%d*%d=\n",num1,num2);
   break;
  case 4:
    num1 = rand()%10;
    num2 = rand()%10+1;
    printf("%d/%d=\n",num1,num2);
   break;
    case 5:
    num1 = rand()%100+1;
    num2 = rand()%100+1;
    printf("%d/%d+%d/%d=\n",num1,num3,num2,num4);
   break;
  case 6:
    num1 = rand()%100+1;
    num2 = rand()%100+1;
    printf("%d/%d-%d/%d=\n",num1,num3,num2,num4);
   break;
  case 7:
    num1 = rand()%10;
    num2 = rand()%10;
    printf("%d/%d*%d/%d=\n",num1,num3,num2,num4);
   break;
  case 8:
    num1 = rand()%10;
    num2 = rand()%10+1;
    printf("%d/%d/%d/%d=\n",num1,num3,num2,num4);
   break;
  }
}
}

  

以上是关于作业三:代码复审的主要内容,如果未能解决你的问题,请参考以下文章

作业三: 代码规范代码复审PSP

作业三: 代码规范代码复审PSP

作业三: 代码规范代码复审PSP

作业三: 代码规范代码复审PSP

作业三:四则运算复审

个人作业-Week3:代码复审