In this loop:
while(a < 100){
a=a+1;
for(i = 0;i < arr.length;i++){
if(x < arr[i]){
arr2[i] = arr2[i] - z;
x = x - z;
if(x > arr[i]) break;
}
}
}
The ith element may be greater than x causing the break but i+1 may
be less than x and I want to subtract x from i+1, how can I make the loop just skip arr[i] and move on to arr[i+1] without breaking the loop altogether and without starting an iteration from the top?
An example of my output is arr2=(0,0,0,2,0,0,5) where x=3 so my loop terminates at 2 because its less than 3 but I still want to subtract from 5.
I think you maybe intend this, but I cannot imagine what you try to achieve.
Try the algorithm on paper.
On the for loop:
is equivalent to: