合作者:姚志辉:031602142;http://www.cnblogs.com/52wu244/
何宇恒:031692113;http://www.cnblogs.com/hyh1072797231/
总代码(失败了):https://github.com/xiaozhirensan/object-oriented/tree/master
我的部分
void topic(int n,int randn[],int key[],char randc[])
{
int caculate(char c,int a,int b);
int i,j,a,b;
char c[4]={'+','-','*','/'};
srand((unsigned) time(NULL));
for(i=0;i<n;)
{
for(j=0;j<4;j++)
randn[j]=rand()%11;
for(j=0;j<3;j++)
randc[j]=c[rand()%4];
if(randc[1]=='*'||randc[1]=='/')
{
if((randc[0]=='+'||randc[0]=='-')&&(randc[2]=='+'||randc[2]=='-'))
{
a=caculate(randc[0],randn[0],randn[1]);
b=caculate(randc[2],randn[2],randn[3]);
if(caculate(randc[1],a,b)!=-1)
{
printf("(%d%c%d)%c(%d%c%d)=?
",randn[0],randc[0],randn[1],randc[1],randn[2],randc[2],randn[3]);
key[i]=caculate(randc[1],a,b);
i++;
}
else{}
}
else if((randc[0]=='+'||randc[0]=='-')&&(randc[2]=='*'||randc[2]=='/'))
{
a=caculate(randc[0],randn[0],randn[1]);
if(caculate(randc[1],a,randn[2])!=-1)
{
b=caculate(randc[1],a,randn[2]);
if(caculate(randc[2],b,randn[3])!=-1)
{
printf("(%d%c%d)%c%d%c%d=?
",randn[0],randc[0],randn[1],randc[1],randn[2],randc[2],randn[3]);
key[i]=caculate(randc[2],b,randn[3]);
i++;
}
else {}
}
else {}
}
else if((randc[0]=='*'||randc[1]=='/')&&(randc[2]=='+'||randc[2]=='-'))
{
a=caculate(randc[2],randn[2],randn[3]);
if(caculate(randc[0],randn[0],randn[1])!=-1)
{
b=caculate(randc[0],randn[0],randn[1]);
if(caculate(randc[1],b,a)!=-1)
{
printf("%d%c%d%c(%d%c%d)=?
",randn[0],randc[0],randn[1],randc[1],randn[2],randc[2],randn[3]);
key[i]=caculate(randc[1],b,a);
i++;
}
else {}
}
else {}
}
else
{
if(caculate(randc[0],randn[0],randn[1])!=-1)
{
a=caculate(randc[0],randn[0],randn[1]);
if(caculate(randc[1],a,randn[2])!=-1)
{
b=caculate(randc[1],a,randn[2]);
if(caculate(randc[2],b,randn[3])!=-1)
{
printf("%d%c%d%c%d%c%d=?
",randn[0],randc[0],randn[1],randc[1],randn[2],randc[2],randn[3]);
key[i]=caculate(randc[2],b,randn[3]);
i++;
}
else {}
}
else{}
}
else{}
}
}
else
{
if(caculate(randc[0],randn[0],randn[1])!=-1&&caculate(randc[2],randn[2],randn[3])!=-1)
{
a=caculate(randc[0],randn[0],randn[1]);
b=caculate(randc[2],randn[2],randn[3]);
printf("%d%c%d%c%d%c%d=?
",randn[0],randc[0],randn[1],randc[1],randn[2],randc[2],randn[3]);
key[i]=caculate(randc[1],a,b);
i++;
}
else{}
}
}
}
思路:先随机出随机整数,根据中间符号字符是*÷还是+—分情况讨论,在相应的情况下加上括号(错误思路导致错误代码)
规范:含四位整数,括号随机的的,分四个模块
合作过程:主要在QQ上讨论,导致信息的延误,因为不能及时收到和回复,导致代码发现问题的滞后
合作体会:这次的失败体验刻骨铭心,以至于到最后有点怨天尤人,希望上课后可以找回自信