这可能不太优雅.主要是因为我对C++比较陌生,但是这个我正在整理的小程序在这里磕磕绊绊.
我不明白.我误解了数组吗?编辑后的代码是:
int diceArray [6][3][1] = {};
...
}else if (y >= xSuccess || x >= xSuccess){
// from here...
diceArray[2][1][0] = diceArray[2][1][0] + 1;
diceArray[2][1][1] = diceArray[2][1][1] + 1;
// ...to here, diceArray[2][2][0] increases by 1. I am not referencing that part of the array at all. Or am I?
}
Run Code Online (Sandbox Code Playgroud)
通过使用评论,我追踪到了第二个表达式的罪魁祸首.如果我发表评论,第一个diceArray[2][2][0]不会改变.
为什么diceArray[2][1][1] = diceArray[2][1][1] + 1导致diceArray[2][2][0]增加?
我试过了..
c = diceArray[2][1][1] + 1;
diceArray[2][1][1] = c;
Run Code Online (Sandbox Code Playgroud)
..作为解决方法,但它是一样的.它增加diceArray[2][2][0]了一个.