パフォーマンスやメモリの改善はありません。ただし、魔法の数からコードをきれいに保つようにしてください。したがって、コード内のいくつかの場所で定数が繰り返され、それらすべての場所でこの定数が論理的な観点から同じである場合は、名前付き定数にすることをお勧めします。
例:
const int numberOfParticles = 10; //This is just an example, it's better not to use global variables.
void processParticlesPair(int i, int j) {
for (int iteration = 0; iteration < 10; ++iteration) {
//note, that I didn't replace "10" in the line above, because it is not a numberOrParticles,
//but a number of iterations, so it is a different constant from a logical point of view.
//Do stuff
}
}
void displayParticles() {
for (int i = 0; i < numberOfParticles; ++i) {
for (int j = 0; j < numberOfParticles; ++j) {
if (i != j) {
processParticlesPair(i, j);
}
}
}
}