zoukankan      html  css  js  c++  java
  • 软工作业PSP与单元测试训练

    一、实现功能模块;

    二、针对所实现的模块编写对应的单元测试代码;

    #include<stdio.h>
    #include<string.h>
    #include<time.h>
    int strtonum(char *str){
    int num=0;
    for(int i=0;i<strlen(str);i++){
    num=num*10+str[i]-'0';
    }
    return num;
    }
    char verifydate(char *date){
    struct tm *local;
    time_t t;
    t=time(NULL);
    local = localtime(&t);
    int year,month,day,c=local->tm_year;
    char s[5];
    memset(s,0,sizeof(s));
    memcpy(s,date,4);
    year=strtonum(s);
    memset(s,0,sizeof(s));
    memcpy(s,date+4,2);
    month=strtonum(s);
    memset(s,0,sizeof(s));
    memcpy(s,date+6,2);
    day=strtonum(s);
    if(year<1900 || year>(c+1900))return 0;
    if(month<1 || month>12)return 0;
    if(day>31 || day<1)return 0;
    if(day==31){
    if(month==2 || month==4 || month==6 || month==9 || month==11)return 0;
    else return 1;
    }
    if(day==30){
    if(month==2)return 0;
    else return 1;
    }
    if(day==29){
    if(year%4==0){
    if(year%100!=0)return 1;
    else
    if(year%400==0)return 1;
    }
    else return 0;
    }
    return 1;
    }
    void verifyID(char IDnum[]){
    int m[17]={7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2},sum=0;
    char last[11]={'1','0','x','9','8','7','6','5','4','3','2'};
    for(int i=0;i<17;i++){
    sum=sum+((IDnum[i]-'0')*m[i]);
    }
    if(IDnum[17]==last[sum%11])
    printf("该身份证正确! ");
    else
    printf("该身份证无效 ");
    }
    int main()
    {
    char IDnum[18],birthday[8];
    while(1){
    gets(IDnum);
    if(strlen(IDnum)==18){
    memcpy(birthday,IDnum+6,8);
    if(verifydate(birthday)==0)
    printf("该身份证无效 ");
    else
    verifyID(IDnum);
    }
    else
    printf("该身份证格式错误 ");
    }
    return 0;
    }

    三、需要按PSP流程进行工作量估算,填写任务清单工作量估算表。

    任务清单工作量估算表:

    PSP阶段

    时间估算(小时)

    实际实际(小时)

    计划

    估计每个阶段的时间成本

     0.4

    0.6

    开发

    需求分析

     0.5

     0.5

    系统设计

     0.4

     0.6

    设计复审

     0.2

     0.2

    代码实现

     0.2

     0.2

    代码复审

     0.2

     0.2

    测试

     0.2

     0.5

    报告

    测试报告

     0.1

     0.4

    总结

     0.3

     0.5

  • 相关阅读:
    爬弹幕
    写了这么多行就给我30,呜呜呜
    ticket
    yield求平均数
    协程原理
    爬取一类字二类字的信息和笔顺gif图片
    关于CRF的相关阅读
    embedding size与vocabulary size之间的关系: e = v**0.25
    pandas多个值取数
    转 pandas pivot
  • 原文地址:https://www.cnblogs.com/A1Meng/p/8592441.html
Copyright © 2011-2022 走看看