四则运算题目生成器

1 预估时间及实际花费时间表格

PSP2.1Personal Software Process StagesTime
Planning 计划  
· Estimate · 估计这个任务需要多少时间 50h
Development 开发  
· Analysis · 需求分析 (包括学习新技术) 10h
· Design Spec · 生成设计文档 1h
· Design Review · 设计复审 (和同事审核设计文档) 1h
· Coding Standard · 代码规范 (为目前的开发制定合适的规范) 0.5h
· Design · 具体设计 2h
· Coding · 具体编码 15h
· Code Review · 代码复审 1h
· Test · 测试(自我测试,修改代码,提交修改) 5h
Reporting 报告  
· Test Report · 测试报告 1h
· Size Measurement · 计算工作量 0.5h
· Postmortem & Process Improvement Plan · 事后总结, 并提出过程改进计划 1h
  合计 38h

2 性能分析图

 

3 测试用例

-n 100 -r 5 -e exercise.txt -a answer.txt

-n 1000 -r 5 -e exercise.txt -a answer.txt

-n 10000 -r 5 -e exercise.txt -a answer.txt

-n 10 -r 5 -e exercise.txt -a answer.txt

-n 1 -r 5 -e exercise.txt -a answer.txt

-n 100 -r 2 -e exercise.txt -a answer.txt

-n 100 -r 10 -e exercise.txt -a answer.txt

-n 100 -r 1 -e exercise.txt -a answer.txt

-n 100 -r 3 -e exercise.txt -a answer.txt

-n 100 -r 4 -e exercise.txt -a answer.txt

-n 100 -r 100 -e exercise.txt -a answer.txt

 

 

4 收货

c语言

1
typedef struct Formula{
    int model;
    int op[3];
    double ui[4];
};

int compare(struct Formula f[],int j,int m1,int op1[],double uf1[]){}
compare(formula,j,m1,op1,uf1)

2
int compare(struct Formula f[],int *j,int m1,int op1[],double uf1[]){}
compare(formula,&j,m1,op1,uf1)
参数传递指针

3
memcpy(s,s1,sizeof(s1))

4
求任意个自然数的平方和:
int SqSum(int n1, ...)
{
va_list arg_ptr;
int nSqSum = 0, n = n1;
va_start(arg_ptr, n1);
while (n > 0)
{
    nSqSum += (n * n);
    n = va_arg(arg_ptr, int);
}
va_end(arg_ptr);
return nSqSum;
}
// 调用时
int nSqSum = SqSum(7, 2, 7, 11, -1);
可变参数函数的原型声明格式为:
type VAFunction(type arg1, type arg2, … );
va_list arg_ptr:定义一个指向个数可变的参数列表指针;
va_start(arg_ptr, argN):使参数列表指针arg_ptr指向函数参数列表中的第一个可选参数
va_arg(arg_ptr, type):返回参数列表中指针arg_ptr所指的参数,返回类型为type,并使指针

arg_ptr指向参数列表中下一个参数。
va_copy(dest, src):dest,src的类型都是va_list,va_copy()用于复制参数列表指针,将dest初始

化为src。
va_end(arg_ptr):清空参数列表,并置参数指针arg_ptr无效。

void stringcat(char ss[],char s1[],...){
    va_list arg_ptr;
    char s[1000];
    memcpy(s,s1,sizeof(s1));
    va_start(arg_ptr,ss);
    while(s){
        strcat(ss,s);
        memcpy(s,va_arg(arg_ptr,char*),sizeof(va_arg(arg_ptr,char*)));
    }
    va_end(arg_ptr);
}

5
数字转字符串
itoa(int i,char* s,进制)
sprintf(char*,"%d",a)

c++
6
#include<ctime>
srand( unsigned( time(0) ) );

7
string in;
end = in.find("/",begin);
fenziStr = in.substr(begin,end - begin);
fenzi = atoi(fenziStr.c_str());

8
ifstream exTxt(a,ios::in);
ifstream anTxt(b,ios::in);
ofstream out1("exercise.txt",ios::out);
out1.close();
ofstream out2("answer.txt",ios::out);
out2.close();

posted on 2015-09-22 22:36  周文祥  阅读(178)  评论(1编辑  收藏  举报