一、

这篇博客要对上次实现的四则运算进行单元测试,一是检查上次的程序的实现情况,二是巩固单元测试的相关知识。本次进行单元测试用的是Riget-BICEP方法。

Riget-BICEP方法:

1、Right-结果是否正确?
            2、B-是否所有的边界条件都是正确的?
            3、I-能查一下反向关联吗?
            4、C-能用其他手段交叉检查一下结果吗?
            5、E-你是否可以强制错误条件发生?
            6、P-是否满足性能要求?

对应于以上的六个值得测试的部位,选择适合本程序的测试方法进行测试如下:

1、运算式多少的测试:分为运算式个数比较少和运算式比较多两种情况,看看结果如何

首先是5个运算式:运行时间较快

运算式数量增加为300个:运算时间较长

运算出现错误,错误为求余数是,方程rand()%a中,a出现负数的情况。经过对a的不同值的判断处理,修改程序后,结果为:

2、控制能否有乘除法

没有的情况:

有的情况:

3、控制是否能有有负数出现

不能有负数出现;

4、测试能否有余数出现

不能有余数出现:

5、测试可以有括号生成

6、测试能否输出运算式到文件:

二、根据代码风格规范修改后的程序为

 //第三次实验
#include<iostream>
#include<string>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<fstream>
using namespace std; int main()
{
int intExpressieCanYu[][]; //这是一个二维数组,每行记录的是每个运算式中参与的数字
int intExpressieNumNum[]; //此数组记录二维数组相应行中的列数,及记录每个运算式中参与运算的数字的个数
int intNumber; //定义产生的运算式中数的数量(最大为10个数)
int intExpressieNum; //定义产生的运算式的数量
int intPrintStyle; //定义打印方式(DOS界面打印、输出到文件)
int intMultiplyDivide; //定义是否有乘除法,0代表没有,1代表有
int intMax, min; //定义四则运算中的数的取值范围
int intMinus; //定义是否有负数,0代表没有,1代表有
int intRemainder; //定义是否有余数,0代表没有,1代表有
int intBracket; //定义是否有括号,0代表没有,1代表有 int intBiaozhiwei[]; //标志位,记录各个条件 cout << "请输入要生成的运算式的数量:";
cin >> intExpressieNum;
cout << endl;
cout << "请输入打印运算式的方式(0代表DOS界面,1代表输出到文件):";
cin >> intPrintStyle;
cout << endl;
cout << "运算式中是否含有乘除法(0代表没有,1代表有):";
cin >> intMultiplyDivide;
cout << endl;
cout << "请输入运算式中数的取值范围(输入方式为:最小值 空格 最大值):";
cin >> min >> intMax;
cout << endl;
cout << "运算过程能否出现负数(0代表不能,1代表能)";
cin >> intMinus;
cout << endl;
cout << "定义运算过程是否能够有余数出现(0代表不能出现余数,1代表能出现)";
cin >> intRemainder;
cout << endl;
cout << "定义括号是否能够参与运算(0代表不能,1代表能)";
cin >> intBracket;
cout << endl; intBiaozhiwei[] = intExpressieNum;
intBiaozhiwei[] = intPrintStyle;
intBiaozhiwei[] = intMultiplyDivide;
intBiaozhiwei[] = min;
intBiaozhiwei[] = intMax;
intBiaozhiwei[] = intMinus;
intBiaozhiwei[] = intRemainder;
intBiaozhiwei[] = intBracket; ofstream outfile;
outfile.open("f1.dat", ios::out);
//首先根据运算式的数量,生成每个运算式需要的数,并记录在intExpressieCanYu[1000][10]中
srand((int)time()); //根据时间生成随机数种子
int xun_huan_expressieNum; //此变量代表循环时的记录,代表已经循环的次数
for (xun_huan_expressieNum = ; xun_huan_expressieNum < intExpressieNum; xun_huan_expressieNum++)
{
intNumber = + rand() % ; //随机生成参与每个式子进行运算的数的个数
intExpressieNumNum[xun_huan_expressieNum] = intNumber; //将每个式子中数字的个数存入数组intExpressieNumNum[1000]中 for (int i = ; i < intNumber; i++) //根据intNumber生成式子中的每个随机数
{
intExpressieCanYu[xun_huan_expressieNum][i] = min + rand() % (intMax - min); //此处可能有错
}
} //以上完成了数组的初始化,下面要完成运算式的组装 srand((int)time(NULL));
for (int i = ; i < intExpressieNum; i++) //对N个运算式进行循环
{ if ( == intBracket) //如果没有括号
{
int yunsuanfugeshu; //变量运算符的个数
yunsuanfugeshu = intExpressieNumNum[i] - ;
char yunsuanfu[]; //此数组存储运算符 for (int j = ; j < yunsuanfugeshu; j++) //对运算符数组进行赋值
{
if ( == intMultiplyDivide) //如果没有乘除法
{
int sign_noMD; //数字代表符号
sign_noMD = + rand() % ;
if ( == sign_noMD)
{
yunsuanfu[j] = '+';
}
else
{
yunsuanfu[j] = '-';
}
}
else
{
int sign_yesMD; //数字代表运算符,且含有乘除法
sign_yesMD = + rand() % ;
if ( == sign_yesMD)
{
yunsuanfu[j] = '+';
}
else if ( == sign_yesMD)
{
yunsuanfu[j] = '-';
}
else if ( == sign_yesMD)
{
yunsuanfu[j] = '*';
}
else if ( == sign_yesMD)
{
yunsuanfu[j] = '/';
}
}
} //运算符不能有连续3个为除号
for (int ai = ; ai < yunsuanfugeshu; ai++)
{
if (yunsuanfu[ai] == '/')
{
if (yunsuanfu[ai + ] == '/')
{
if (yunsuanfu[ai + ] == '/')
{
yunsuanfu[ai + ] = '+';
}
}
}
} //cout << "运算符的个数为:" << yunsuanfugeshu << endl;
//输出所有运算符号
/*cout << "所有运算符号为:";
for (int fuhaoshu1 = 0; fuhaoshu1 < yunsuanfugeshu; fuhaoshu1++)
{
cout << yunsuanfu[fuhaoshu1] << " ";
}
*/
//上面的循环是对运算符号的赋值。下面组合运算式
//此时已存在数组intExpressieCanYu[i][0-intNumber](参与运算的数字的个数),yunsuanfu[10](存储运算符),yunsuanfugeshu(运算符个数)
if ( == intMultiplyDivide) //如果没有乘除法
{
if ( == intMinus) //如果不能有负数出现
{
int jieguo;
jieguo = intExpressieCanYu[i][]; //结果等于此行数组中的第一个数值 //下面的循环是对运算式预算过程有无负数的判断
for (int nointMinusNum = ; nointMinusNum < (intExpressieNumNum[i] - ); nointMinusNum++)
{
if (yunsuanfu[nointMinusNum] == '+')
{
jieguo = jieguo + intExpressieCanYu[i][nointMinusNum + ]; }
else
{
jieguo = jieguo - intExpressieCanYu[i][nointMinusNum + ];
if (jieguo <= )
{
int a;
a = jieguo;
int b;
b = jieguo + intExpressieCanYu[i][nointMinusNum + ];
if (a < )
{
a = abs(a);
intExpressieCanYu[i][nointMinusNum + ] = b - rand() % (a);
}
if (a == )
{
intExpressieCanYu[i][nointMinusNum + ] = b - rand() % b;
} }
}
} //对运算式进行输出
//cout << "运算式中数的个数为:" << intExpressieNumNum[i] << endl;
if ( == intPrintStyle)
{
int fuhao = ;
for (int shu = ; shu < intExpressieNumNum[i]; shu++)
{
cout << intExpressieCanYu[i][shu]; for (; fuhao < yunsuanfugeshu;)
{
cout << yunsuanfu[fuhao];
fuhao++;
break;
}
}
}
else
{ int fuhao = ;
for (int shu = ; shu < intExpressieNumNum[i]; shu++)
{
outfile << intExpressieCanYu[i][shu]; for (; fuhao < yunsuanfugeshu;)
{
outfile << yunsuanfu[fuhao];
fuhao++;
break;
}
}
outfile << endl;
//outfile.close();
} }
else //如果能有负数出现
{
//对运算式进行输出
//cout << "运算式中数的个数为:" << intExpressieNumNum[i] << endl;
if ( == intPrintStyle)
{
int fuhao = ;
for (int shu = ; shu < intExpressieNumNum[i]; shu++)
{
cout << intExpressieCanYu[i][shu]; for (; fuhao < yunsuanfugeshu;)
{
cout << yunsuanfu[fuhao];
fuhao++;
break;
}
}
}
else
{ int fuhao = ;
for (int shu = ; shu < intExpressieNumNum[i]; shu++)
{
outfile << intExpressieCanYu[i][shu]; for (; fuhao < yunsuanfugeshu;)
{
outfile << yunsuanfu[fuhao];
fuhao++;
break;
}
}
outfile << endl;
//outfile.close();
}
}
}
else //如果有乘除法
{
if ( == intRemainder) //如果不能有余数
{
int intExpressieCanYu_linshi[]; //建立临时数组,下面的循环为给临时数组赋值
for (int linshi_chengchu = ; linshi_chengchu < intExpressieNumNum[i]; linshi_chengchu++)
{
intExpressieCanYu_linshi[linshi_chengchu] = intExpressieCanYu[i][linshi_chengchu];
}
char yunsuanfulinshi[];
for (int yunsuanfujishu2 = ; yunsuanfujishu2 < yunsuanfugeshu; yunsuanfujishu2++)
{
yunsuanfulinshi[yunsuanfujishu2] = yunsuanfu[yunsuanfujishu2];
}
for (int chengchui = ; chengchui < yunsuanfugeshu; chengchui++) //此循环对数组中的余数情况进行调整
{
if (yunsuanfulinshi[chengchui] == '*')
{
int jieguo;
jieguo = intExpressieCanYu_linshi[chengchui] * intExpressieCanYu_linshi[chengchui + ];
intExpressieCanYu_linshi[chengchui] = jieguo;
intExpressieCanYu_linshi[chengchui + ] = jieguo;
yunsuanfulinshi[chengchui] = '+';
}
if (yunsuanfulinshi[chengchui] == '/')
{
int jieguo;
jieguo = intExpressieCanYu_linshi[chengchui] % intExpressieCanYu_linshi[chengchui + ];
if (jieguo != ) //如果有余数
{
int yueshu = ;//约数
int yushupan = ;
while (yushupan < )
{
int jieguoyue;
jieguoyue = intExpressieCanYu_linshi[chengchui] % yueshu;
if (jieguoyue == )
{
yushupan += ;
if (yushupan == )
{
intExpressieCanYu_linshi[chengchui + ] = yueshu; //修改临时数组
intExpressieCanYu[i][chengchui + ] = yueshu; //修改原数组
yunsuanfulinshi[chengchui] = '+';
break;
}
}
yueshu += ;
}
}
}
} if ( == intMinus) //如果不能有负数
{
//下面的大循环时修改乘法或除法前面的一个运算符号为加号
for (int gaijiahao = ; gaijiahao < yunsuanfugeshu; gaijiahao++)
{
if (yunsuanfu[gaijiahao] == '*')
{
for (int gaijiahao1 = gaijiahao - ; gaijiahao1 >= ; gaijiahao1--)
{
if ((yunsuanfu[gaijiahao1] == '+') || (yunsuanfu[gaijiahao1] == '-'))
{
yunsuanfu[gaijiahao1] = '+';
break;
}
}
}
if (yunsuanfu[gaijiahao] == '/')
{
for (int gaijiahao2 = gaijiahao - ; gaijiahao2 >= ; gaijiahao2--)
{
if ((yunsuanfu[gaijiahao2] == '+') || (yunsuanfu[gaijiahao2] == '-'))
{
yunsuanfu[gaijiahao2] = '+';
if (yunsuanfu[gaijiahao2 + ] == '-')
{
yunsuanfu[gaijiahao2 + ] = '+';
} break;
}
}
}
}
//以上为修改乘法和除法符号前边的符号+
//以下为判断正负
for (int fuhaochuan = ; fuhaochuan < yunsuanfugeshu; fuhaochuan++)
{
if (yunsuanfu[fuhaochuan] == '-')
{
intExpressieCanYu[i][fuhaochuan + ] = + rand() % (intExpressieCanYu[i][fuhaochuan]);
}
} /*cout << "运算符数组为:";
for (int linshia = 0; linshia < yunsuanfugeshu; linshia++)
{
cout << yunsuanfu[linshia];
}
cout << endl;*/
//对运算式进行输出
//cout << "运算式中数的个数为:" << intExpressieNumNum[i] << endl;
//修改数组中的负数为1
for (int qi = ; qi < intExpressieNumNum[i]; qi++)
{
if (intExpressieCanYu[i][qi] < )
{
intExpressieCanYu[i][qi] = ;
}
}
if ( == intPrintStyle)
{
int fuhao = ;
for (int shu = ; shu < intExpressieNumNum[i]; shu++)
{
cout << intExpressieCanYu[i][shu]; for (; fuhao < yunsuanfugeshu;)
{
cout << yunsuanfu[fuhao];
fuhao++;
break;
}
}
}
else
{ int fuhao = ;
for (int shu = ; shu < intExpressieNumNum[i]; shu++)
{
outfile << intExpressieCanYu[i][shu]; for (; fuhao < yunsuanfugeshu;)
{
outfile << yunsuanfu[fuhao];
fuhao++;
break;
}
}
outfile << endl;
//outfile.close();
}
}
else //如果能有负数
{
//对运算式进行输出
//cout << "运算式中数的个数为:" << intExpressieNumNum[i] << endl;
if ( == intPrintStyle)
{
int fuhao = ;
for (int shu = ; shu < intExpressieNumNum[i]; shu++)
{
cout << intExpressieCanYu[i][shu]; for (; fuhao < yunsuanfugeshu;)
{
cout << yunsuanfu[fuhao];
fuhao++;
break;
}
}
}
else
{ int fuhao = ;
for (int shu = ; shu < intExpressieNumNum[i]; shu++)
{
outfile << intExpressieCanYu[i][shu]; for (; fuhao < yunsuanfugeshu;)
{
outfile << yunsuanfu[fuhao];
fuhao++;
break;
}
}
outfile << endl;
//outfile.close();
}
}
}
else //如果可以有余数
{
if ( == intMinus) //如果不能有负数
{
//下面的大循环时修改乘法或除法前面的一个运算符号为加号
for (int gaijiahao = ; gaijiahao < yunsuanfugeshu; gaijiahao++)
{
if (yunsuanfu[gaijiahao] == '*')
{
for (int gaijiahao1 = gaijiahao - ; gaijiahao1 >= ; gaijiahao1--)
{
if ((yunsuanfu[gaijiahao1] == '+') || (yunsuanfu[gaijiahao1] == '-'))
{
yunsuanfu[gaijiahao1] = '+';
}
}
}
if (yunsuanfu[gaijiahao] == '/')
{
for (int gaijiahao2 = gaijiahao - ; gaijiahao2 >= ; gaijiahao2--)
{
if ((yunsuanfu[gaijiahao2] == '+') || (yunsuanfu[gaijiahao2] == '-'))
{
yunsuanfu[gaijiahao2] = '+';
}
}
}
}
//以上为修改乘法和除法符号前边的符号+
//以下为判断正负
for (int fuhaochuan = ; fuhaochuan < yunsuanfugeshu; fuhaochuan++)
{
if (yunsuanfu[fuhaochuan] == '-')
{
intExpressieCanYu[i][fuhaochuan + ] = + rand() % (intExpressieCanYu[i][fuhaochuan + ]);
}
} //对运算式进行输出
//cout << "运算式中数的个数为:" << intExpressieNumNum[i] << endl;
if ( == intPrintStyle)
{
int fuhao = ;
for (int shu = ; shu < intExpressieNumNum[i]; shu++)
{
cout << intExpressieCanYu[i][shu]; for (; fuhao < yunsuanfugeshu;)
{
cout << yunsuanfu[fuhao];
fuhao++;
break;
}
}
}
else
{ int fuhao = ;
for (int shu = ; shu < intExpressieNumNum[i]; shu++)
{
outfile << intExpressieCanYu[i][shu]; for (; fuhao < yunsuanfugeshu;)
{
outfile << yunsuanfu[fuhao];
fuhao++;
break;
}
}
outfile << endl;
//outfile.close();
}
}
else //如果能有负数
{
//对运算式进行输出
//cout << "运算式中数的个数为:" << intExpressieNumNum[i] << endl;
if ( == intPrintStyle)
{
int fuhao = ;
for (int shu = ; shu < intExpressieNumNum[i]; shu++)
{
cout << intExpressieCanYu[i][shu]; for (; fuhao < yunsuanfugeshu;)
{
cout << yunsuanfu[fuhao];
fuhao++;
break;
}
}
}
else
{ int fuhao = ;
for (int shu = ; shu < intExpressieNumNum[i]; shu++)
{
outfile << intExpressieCanYu[i][shu]; for (; fuhao < yunsuanfugeshu;)
{
outfile << yunsuanfu[fuhao];
fuhao++;
break;
}
}
outfile << endl;
//outfile.close();
}
}
} }
}
else //如果有括号
{
//以下各个变量为个数的定义
int yunsuanfugeshu; //变量运算符的个数
yunsuanfugeshu = intExpressieNumNum[i] - ;
char yunsuanfu[]; //此数组存储运算符 int zuidakuohaoshu; //最大括号对数
if (intExpressieNumNum[i] > )
{
zuidakuohaoshu = intExpressieNumNum[i] - ;
}
else
{
zuidakuohaoshu = intExpressieNumNum[i] - ;
} int suijidekuohaoduishu; //随机的括号的对数
if (zuidakuohaoshu > )
{
suijidekuohaoduishu = + rand() % ;
}
else
{
suijidekuohaoduishu = + rand() % zuidakuohaoshu;
}
int kuohaogeshu = * suijidekuohaoduishu; //总的括号数,不是对数
char zifushuzu[]; //定义字符数组,存储括号和运算符
int zifushuzulength = kuohaogeshu + yunsuanfugeshu; //括号和运算符的总长度 //对字符数组进行初始化
for (int chushihua = ; chushihua < ; chushihua++)
{
zifushuzu[chushihua] = 'n';
} //以下循环为运算符数组赋值
for (int j = ; j < yunsuanfugeshu; j++) //对运算符数组进行赋值
{
if ( == intMultiplyDivide) //如果没有乘除法
{
int sign_noMD; //数字代表符号
sign_noMD = + rand() % ;
if ( == sign_noMD)
{
yunsuanfu[j] = '+';
}
else
{
yunsuanfu[j] = '-';
}
}
else
{
int sign_yesMD; //数字代表运算符,且含有乘除法
sign_yesMD = + rand() % ;
if ( == sign_yesMD)
{
yunsuanfu[j] = '+';
}
else if ( == sign_yesMD)
{
yunsuanfu[j] = '-';
}
else if ( == sign_yesMD)
{
yunsuanfu[j] = '*';
}
else if ( == sign_yesMD)
{
yunsuanfu[j] = '/';
}
}
} //以下将几对括号存入二维数组中
char kuohaoshuzu[][];
for (int kuohaojishu = ; kuohaojishu < suijidekuohaoduishu; kuohaojishu++)
{
kuohaoshuzu[kuohaojishu][] = '(';
kuohaoshuzu[kuohaojishu][] = ')';
} //对括号二维数组中的每行进行选择,选择在上面定义的字符数组中的位置
//以下不考虑括号在不在字符数组的首位有两种不同的情况,所以在此不考虑在首位的情况
srand((int)time());
for (int erweishuzuhangshu = ; erweishuzuhangshu < suijidekuohaoduishu; erweishuzuhangshu++)
{
int zuosuijishuweizhi; //此变量代表生成一个随机数,此随机数代表左括号的位置
int yousuijishuweizhi; //此变量代表生成一个随机数,此随机数代表有括号的位置 if (zifushuzulength == )
{
zifushuzu[] = '(';
zifushuzu[] = ')';
}
else
{
int n1 = , n2 = ; //退出循环的标记
zuosuijishuweizhi = + rand() % (zifushuzulength - ); //此处可能出错
while (n1 != )
{
if (zifushuzu[zuosuijishuweizhi] == 'n')
{
zifushuzu[zuosuijishuweizhi] = '(';
n1 = ;
}
else
{
zuosuijishuweizhi = + rand() % (zifushuzulength - );
}
}
int aa = zuosuijishuweizhi + ;
yousuijishuweizhi = aa + rand() % (zifushuzulength - aa);
while (n2 != )
{
if (zifushuzu[yousuijishuweizhi] == 'n')
{
zifushuzu[yousuijishuweizhi] = ')';
n2 = ;
}
else
{
int aa = zuosuijishuweizhi + ;
yousuijishuweizhi = aa + rand() % (zifushuzulength - aa);
}
}
} } //将运算符数组加入到字符数组中
for (int yunsuanfujishu = ; yunsuanfujishu < yunsuanfugeshu; yunsuanfujishu++)
{
for (int qq = ; qq < zifushuzulength; qq++)
{
if (zifushuzu[qq] == 'n')
{
zifushuzu[qq] = yunsuanfu[yunsuanfujishu];
break;
}
}
} //校正字符数组,使得其中不能有相邻的括号
//下面是校正左括号
for (int xianlinkuohao = ; xianlinkuohao < (zifushuzulength - ); xianlinkuohao++)
{
if (zifushuzu[xianlinkuohao] == '(' && zifushuzu[xianlinkuohao + ] == ')')
{
for (int ji = ; ji < zifushuzulength; ji++)
{
if ((zifushuzu[ji] != '(') && (zifushuzu[ji] != ')') && (zifushuzu[ji + ] != ')') && (zifushuzu[ji - ] != ')'))
{
char a;
a = zifushuzu[ji];
zifushuzu[ji] = zifushuzu[xianlinkuohao];
zifushuzu[xianlinkuohao] = a;
break;
}
}
}
if (zifushuzu[xianlinkuohao] == ')' && zifushuzu[xianlinkuohao + ] == '(')
{
for (int ji = ; ji < zifushuzulength; ji++)
{
if ((zifushuzu[ji] != '(') && (zifushuzu[ji] != ')') && (zifushuzu[ji + ] != ')') && (zifushuzu[ji - ] != ')'))
{
char a;
a = zifushuzu[ji];
zifushuzu[ji] = zifushuzu[xianlinkuohao + ];
zifushuzu[xianlinkuohao + ] = a;
break;
}
}
}
}
//下面是校正右括号
for (int xianlinkuohao = ; xianlinkuohao < (zifushuzulength - ); xianlinkuohao++)
{
if (zifushuzu[xianlinkuohao] == '(' && zifushuzu[xianlinkuohao + ] == ')')
{
for (int ji = ; ji < zifushuzulength; ji++)
{
if ((zifushuzu[ji] != '(') && (zifushuzu[ji] != ')') && (zifushuzu[ji + ] != '(') && (zifushuzu[ji - ] != '('))
{
char a;
a = zifushuzu[ji];
zifushuzu[ji] = zifushuzu[xianlinkuohao + ];
zifushuzu[xianlinkuohao + ] = a;
break;
}
}
}
if (zifushuzu[xianlinkuohao] == ')' && zifushuzu[xianlinkuohao + ] == '(')
{
for (int ji = ; ji < zifushuzulength; ji++)
{
if ((zifushuzu[ji] != '(') && (zifushuzu[ji] != ')') && (zifushuzu[ji + ] != '(') && (zifushuzu[ji - ] != '('))
{
char a;
a = zifushuzu[ji];
zifushuzu[ji] = zifushuzu[xianlinkuohao];
zifushuzu[xianlinkuohao] = a;
break;
}
}
}
} //cout << "括号的个数为:" << kuohaogeshu<< endl;
//cout << "运算符的个数为:" << yunsuanfugeshu<< endl;
//cout << "字符数组的个数为:" << zifushuzulength << endl;
//对字符数组进行输出
/*cout << "字符数组为:";
for (int ii = 0; ii < zifushuzulength; ii++)
{
cout << zifushuzu[ii] << " ";
}
cout << endl;
*/
/*//对运算式进行输出
int fuhaojishus0=0;
if (zifushuzulength == 3)
{
cout << "(" << intExpressieCanYu[i][0] << yunsuanfu[0] << intExpressieCanYu[i][1] << ")";
}
else
{
for (int shuchushuzi = 0; shuchushuzi < intExpressieNumNum[i]; shuchushuzi++)
{
cout << intExpressieCanYu[i][shuchushuzi];
for (; fuhaojishus0 < zifushuzulength;)
{
while (zifushuzu[fuhaojishus0] == ')')
{
cout << ")";
fuhaojishus0 += 1;
}
if (fuhaojishus0 < zifushuzulength)
{
cout << zifushuzu[fuhaojishus0]; //输出右括号紧邻的运算符或者是输出第一个符号
} fuhaojishus0 += 1;
while (zifushuzu[fuhaojishus0] == '(')
{
cout << "(";
fuhaojishus0 += 1;
}
break;
}
}
}*/ if ( == intPrintStyle)
{
int fuhaojishus0 = ;
if (zifushuzulength == )
{
cout << "(" << intExpressieCanYu[i][] << yunsuanfu[] << intExpressieCanYu[i][] << ")";
}
else
{
for (int shuchushuzi = ; shuchushuzi < intExpressieNumNum[i]; shuchushuzi++)
{
cout << intExpressieCanYu[i][shuchushuzi];
for (; fuhaojishus0 < zifushuzulength;)
{
while (zifushuzu[fuhaojishus0] == ')')
{
cout << ")";
fuhaojishus0 += ;
}
if (fuhaojishus0 < zifushuzulength)
{
cout << zifushuzu[fuhaojishus0]; //输出右括号紧邻的运算符或者是输出第一个符号
} fuhaojishus0 += ;
while (zifushuzu[fuhaojishus0] == '(')
{
cout << "(";
fuhaojishus0 += ;
}
break;
}
}
}
}
else
{
int fuhaojishus0 = ;
if (zifushuzulength == )
{
outfile << "(" << intExpressieCanYu[i][] << yunsuanfu[] << intExpressieCanYu[i][] << ")";
outfile << endl;
}
else
{
for (int shuchushuzi = ; shuchushuzi < intExpressieNumNum[i]; shuchushuzi++)
{
outfile << intExpressieCanYu[i][shuchushuzi];
for (; fuhaojishus0 < zifushuzulength;)
{
while (zifushuzu[fuhaojishus0] == ')')
{
outfile << ")";
fuhaojishus0 += ;
}
if (fuhaojishus0 < zifushuzulength)
{
outfile << zifushuzu[fuhaojishus0]; //输出右括号紧邻的运算符或者是输出第一个符号
} fuhaojishus0 += ;
while (zifushuzu[fuhaojishus0] == '(')
{
outfile << "(";
fuhaojishus0 += ;
}
break;
}
}
outfile << endl;
}
} } cout << endl;
} outfile.close(); return ; }

四则运算之Right-BICEP单元测试的更多相关文章

  1. BICEP单元测试——随机四则运算升级版

    一.测试方法 6个值得测试的具体部位: Right-结果是否正确? B-是否所有的边界条件都是正确的? I-能查一下反向关联吗? C-能用其他手段交叉检查一下结果吗? E-你是否可以强制错误条件发生? ...

  2. 软工+C(2017第6期) 最近发展区/脚手架

    // 上一篇:工具和结构化 // 下一篇:野生程序员 教育心理学里面有提到"最近发展区"这个概念,这个概念是前苏联发展心理学家维果茨基(Vygotsky)提出的,英文名词是Zone ...

  3. 软工+C(6): 最近发展区/脚手架

    // 上一篇:工具和结构化 // 下一篇:野生程序员 教育心理学里面有提到"最近发展区"这个概念,这个概念是前苏联发展心理学家维果茨基(Vygotsky)提出的,英文名词是Zone ...

  4. 结对练习——Caculator

    本人:学号201521031045,码云https://gitee.com/L_Name 小伙伴:暂无 项目fork: https://gitee.com/L_Name/Calculator CalS ...

  5. RIGHT-BICEP单元测试——“二柱子四则运算升级版”

    RIGHT-BICEP单元测试 ——“二柱子四则运算升级版” ”单元测试“这对于我们来说是一个全新的专业含义,在上了软件工程这门课,并当堂编写了简单的"求一组数中的最大值"函数的单 ...

  6. 【week3】四则运算 单元测试

    上一周的四则运算有bug,这次补充正确代码: // 中缀转后缀 public String[] SolveOrder(String[] in, HashMap<String, Integer&g ...

  7. 单元测试--四则运算2程序(c++)

    源代码: //2016 3.6 Cheng Qiqin //四则运算改进 #include <iostream> #include<ctime> #include<cst ...

  8. 四则运算之Right-BICEP测试

    Right-结果是否正确? 正确 B-是否所有的边界条件都是正确的? Conformance(一致性):值是否和预期的一致  是一致的 Ordering(顺序性):值是否如应该的那样 是 是有序或者无 ...

  9. 四则运算<3>单元测试

    经过分析图一的结果正确,因为输出到文件是为了打印,不要求在线答题功能,因此为实现答题功能. 经过分析,结果正确,满足了选择要求. 选择这六组测试用例的原因是这六组用例将有无乘数法,有无括号,有无负数, ...

随机推荐

  1. Linux双网卡绑定

    Linux双网卡绑定 作者:Eric 微信:loveoracle11g eth0和eth1绑定为bond0 [root@rac-node1 ~]# cat /etc/sysconfig/network ...

  2. [SQL]SQL中EXISTS的用法

    比如在Northwind数据库中有一个查询为SELECT c.CustomerId,CompanyName FROM Customers cWHERE EXISTS(SELECT OrderID FR ...

  3. jquery选择器筛选器

    jQuery对象 Query 对象就是通过jQuery包装DOM对象后产生的对象.jQuery 对象是 jQuery 独有的. 如果一个对象是 jQuery 对象, 那么它就可以使用 jQuery 里 ...

  4. JS弹框

    <script type="text/javascript"> function show_alert() { alert('警报'); } function show ...

  5. Java基础方面

    1.作用域public,private,protected,以及不写时的区别 答:区别如下: 作用域        当前类     同一package       子孙类     其他package ...

  6. Windows向虚拟机Linux传输文件方法

    在Windows中装了个centOS,进行文件操作时,把mv写成了rm,然后就悲剧了.. 赶紧从网上找来文件的具体内容,然后由Windows向Linux挂载共享文件夹. 具体做法: 在Windows中 ...

  7. 自动创建表出错 type=InnDB

    因为type=InnoDB在5.0以前是可以使用的,但5.1之后就不行了 只需要修改配置: hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDia ...

  8. Java框架相关

    问题及答案来源自<Java程序员面试笔试宝典>第五章 Java Web 5.3 框架 11.什么是IoC? IoC:控制反转(Inverse of Control, IoC),有时候也被称 ...

  9. [Oracle,2018-01-11] 导出数据库说明文档

    select A.table_name,A.column_name,A.data_type,A.DATA_LENGTH,B.comments from user_tab_columns A,user_ ...

  10. 【Selenium-WebDriver自学】Selenium网格化(十六)

    参考链接: http://www.yiibai.com/selenium/selenium_grids.html 命令: cd E:\Yingpu\000.SVNYP\01.个人文件夹\Renqian ...