How to exclude a number from command 'for'?

Good night, everyone..
Just wondering how do I exclude a number from command for 'for'?
For an example:
for (int i = 0; i < 9; ++i) - Except for i = 5?

Thanks!
Only way I can think of would be to put an if statement inside the for, and test for i == 5 and then skip the rest of the code inside the for.
this is the part of the code i will use this:

1
2
3
4
5
6
7
8
9
int main() {
  int n = 25, k = 15;
    
  for (int i = 0; i < n; ++i)  {people.push_back(i+1); }
   go(0, k);
			 
  return 0;
}




I tried the if statement, but can't make it work though... Any light?
What are you trying to "make work"? Your code there seems to be a different issue than the original post.
Either do what squished18 said, and have a test for if (i == 5) {/*do nothing or some special case*/}, or do something like
1
2
3
4
5
6
7
8
for (int i = 0; i < 5; i++)
{
    //do stuff
}
for (int i = 6; i < 9; i++)
{
  //do stuff, i was never 5
}

Show in code the if-statement you tried to implement.
Last edited on
Topic archived. No new replies allowed.