开发者

C++ 4 players in a array after element 3 reset to 0 with modulus [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. 开发者_如何学Go Closed 11 years ago.

4 players in a array after element 3 reset to 0 with modulus. So if its players 3 turn it will reset to player 1 witch is element 0.


Use something like this:

player = (player + 1) % 4;


You're somehow missing your actual question? If you'd like to "loop" some index over 0 to 3 (for 4 players) just do something like this:

int currentPlayer = 0;
int numPlayers = 4;

// ...

currentPlayer = (currentPlayer + 1) % numPlayers;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜