for(int m=0;m<=3;m++){
for(int n=0;n<=3;n++){
if(n>0){
int c =n,t=1;
do{
t = up_key_no0(&puzz[c][m]);
c--;
}while(t==1||c>=0);
}
}
}
int up_key_no0(int *puzy){
int *puzx = puzy -4;
int down = *puzy;
int up = *puzx;
if(((down==up)||(up==0))&&down!=0){
*puzx += *puzy;
*puzy=0;
return 1;
}
else{
return 0;
}
}下面这段代码是不是错了?如果是,则回复。整个代码无法匹配,但puzz是一个4X4的二维数组
发布于 2015-07-08 22:07:54
我不知道语言是这样的,但如果它像Java,"for“应该是这样的:
for (var i=0;i<=3;i++) {
}你的时间可能是错的。while上的"==“应该是"=”。
while(t=1||c>=0) {
}发布于 2015-07-08 22:18:08
当t为1,c为0时,do-while循环可能会超出表的范围,变为负索引。因此,也许您应该将条件更改为(t == 1 && c >= 0) (而不是or)。
https://stackoverflow.com/questions/31292641
复制相似问题