结论:优先采用改进for循环,但在性能要求苛刻的ArrayList迭代中,考虑采用手写计数循环。
To summarize: use the enhanced for loop by default, but consider a hand-written counted loop for performance-critical ArrayList iteration.
但是,如果有一个投票周期,计数循环不已,因为每个候选人至少有一个竞争对手谁得到暂停票超过50 %的选民。
But if there is a voting cycle, the tally loops endlessly because every candidate has at least one rival who gets suspended votes from more than 50% of voters.
在每次循环迭代中增加一个计数。
And obviously, that ought to involve the variable in some way, or it's not going to make a lot of sense, so this includes the variable, since that's the thing that's changing.
很明显,这跟计数器的变量有某种关系,否则的话就没多大意义了,因此这跟计数器有关,因为它正是每次循环改变的东西。
应用推荐