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语句,因为都是左对齐的,很不容易去找到,再结合上面的内容,很不容看明白,这就造成了代码整体的可读性不高,不容易进行维护。

  • 相关阅读:
    Pro*C,oci,occi的作用以及区别联系?
    图片缩放 剪切
    去除DataGridView选中行背景色的方法
    重写DataGridView的sort方法 自定义排序
    很好用的js日历 kimsoftjscalendar 感谢KimSoft
    计时器例子
    gcc与g++有什么区别?
    VB.NET全角半角check
    Java 集合框架(Collection)和数组的排序
    Click Models for Web Search(1) Basic Click Models
  • 原文地址:https://www.cnblogs.com/dys123hahabalala/p/5313780.html
Copyright © 2011-2022 走看看