zoukankan      html  css  js  c++  java
  • 20160317第二题

    代码复审

    我负责的小伙伴是于悦,她用的是c语言,c-free来编写的四则运算,以下是她的代码

    #include<stdio.h>
     
    #include<stdlib.h>
    #include<time.h>
    main()
    {
    int a,b,op,os;
     
    printf(" [四则运算来挑战]
    ");
    aq1:    printf("选择你想挑战的运算法则
    ");
    printf("1.加法 2.减法 3.乘法 4.除法
    ");
    scanf("%d",&op);
    switch(op)
    {
    aq: case 1:
    srand((unsigned)time(NULL));
    a=rand()%100+1;b=rand()%100+1;
    printf("题目为:%d + %d = ?
    
    ",a,b);
    printf("1.查看答案 2.做下一题
    ");
    scanf("%d",&os);
    if(os==1)
    {printf("%d + %d =%d
    
    
    ",a,b,a+b);
    goto aq1;
    }
    else
    goto aq;
    break;
    at:  case 2:a=rand()%100+1;b=rand()%100+1;
    printf("题目为:%d - %d = ?
    
    ",a,b);
    printf("1.查看答案 2.做下一题
    ");
    scanf("%d",&os);
    if(os==1)
    {printf("%d - %d =%d
    
    
    ",a,b,a-b);
    goto aq1;
    }
    else
    goto at;
    break;
    aq2:     case 3:
    a=rand()%100+1;b=rand()%100+1;
    printf("题目为:%d * %d = ?
    
    ",a,b);
    printf("1.查看答案 2.做下一题
    ");
    scanf("%d",&os);
    if(os==1)
    {printf("%d * %d =%d
    
    
    ",a,b,a*b);
    goto aq1;
    }
    else
    goto aq2;
    aq3:     case 4:
    a=rand()%100+1;b=rand()%100+1;
    printf("题目为:%d / %d = ?
    
    ",a,b);
    printf("1.查看答案 2.做下一题
    ");
    scanf("%d",&os);
    if(os==1)
    {printf("%d / %d =%d
    
    
    ",a,b,a/b);
    goto aq1;
    }
    else
    goto aq3;
    break;
    }
    }

    代码的每一行都检查过了,都是没有问题的,也没有一些没必要的代码,而且整个程序都可以运行出来。但是她和我出现了同样的问题,都是没有注释。而且代码的编写也不规范,都没有缩进,比如看if,else语句,因为都是左对齐的,很不容易去找到,再结合上面的内容,很不容看明白,这就造成了代码整体的可读性不高,不容易进行维护。

  • 相关阅读:
    【BZOJ 2844】: albus就是要第一个出场
    BZOJ 2631: tree
    BZOJ1798: [Ahoi2009]Seq 维护序列seq
    Link-Cut Tree指针模板
    bzoj 4916: 神犇和蒟蒻 (杜教筛+莫比乌斯反演)
    【BZOJ 3561】 DZY Loves Math VI
    linux 安装php7.2 以及配置laravel环境(public目录下)
    composer 配置 切换中国镜像
    phpstorm composer 提示php 版本过低的问题调整
    如何在阿里云的虚机 部署laravel项目
  • 原文地址:https://www.cnblogs.com/dys123hahabalala/p/5313780.html
Copyright © 2011-2022 走看看