ArrayIndex|Value|Running total
-------------------------------
0 | 6 | 6
1 | 1 | 7
2 | 6 | 13
3 | 2 | 15
I:array index
V:value
R:Running total
Je dois sélectionner l'indice approprié pour le total courant donné, par exemple 12 est le total courant donné, donc l'indice approprié est 2, je vais mettre mon bloc de code ci-dessous, il ne fonctionne pas, j'ai essayé d'utiliser break ; après l'instruction if ainsi, quelqu'un peut m'aider à résoudre ce problème s'il vous plaît :)
int running_total = 0;
boolean v=false;
for(int x=0;x<=array.length;x++)
{
running_total+=array[x];
if(running_total>=12)
{
if(v==false)
{
v= true;
othermethods(x);
}
}
}