So I have this C function that reads in 6 numbers the must fit a certain pattern to reach the end of the function successfuly.
void phase() {
int numbers[6];
read_six_numbers(numbers);
if(numbers[0] < 0) explode();
for(int i=1; i!=6; ++i) {
int a = i + numbers[i-1];
if(numbers[i]!=a) explode();
}
}
What's throwing me off is the ++i in the loop. I've looked up the difference of ++i vs i++ and it doesn't seem like it really matters when iterating though numbers. Yet, I can't seem to find 6 numbers that would reach the end of this function without explode() being called.
In short, does the ++i vs i++ matter in this case? Like I said, researching the difference, it doesn't seem like it should. Although when I work out the problem on paper I'm unable to reach the end of the loop successfully, so I must be doing something wrong? Or maybe just overthinking the question?
I will gladly close the question if it's just my stupidity causing the confusion.
Aucun commentaire:
Enregistrer un commentaire