Instead of having individual variables like this:
int index1, index2, index3, ...indexN:
you should consider using an array of indices:
int index[N];
and then you can sum in a loop, e.g.
sum = 0;
for (i = 0; i < N; ++i)
{
sum += array[index[i]];
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…