我想在這些支柱之間交替的支柱上放置支柱 (我認爲我沒有正確解釋),但是例如在第1排中它將有9支柱和第2排它會有8個支柱。我想嘗試在嵌套for循環中執行,但不確定如何處理塊中的代碼。支柱的配置
目前,我有這樣的: 這裏是我的變量:
float PegPosX = -1.0f;
float PegYStartPos;
float PegPosY = 6.0f;
int Pegs = 0;
int PegsInRow = 8;
while(Pegs < NumPegs){
for (int row = 0; row < PegsInRow; ++row) {
int num_cols = (row % 2 == 0) ? 9 : 8;
PegPosY -= 0.5f;
for (int col = 0; col < num_cols; ++col){
PegPosX += 1.0f;
displayPegs[Pegs].PegPosition(PegPosX, PegPosY);
}
}
++Pegs;
}
是的,你沒有正確解釋 – 2012-04-18 08:39:15