for loop excluding some values

Hello everyone,
I want to assign a value to a component of an array by excluding some of indices
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  	vector<int>save;
	for (int o = 0; o < nbOdds; ++o) {
		for (int t = 0; t < nbWays; ++t) {
			if (S[o][3] == 1) {
				save.push_back(o);
			}		
		}
	}

	for (int o = 0; o < nbOdds; ++o) {
		for (int t = 0; t < nbWays; ++t) {
			if(o!= save[o])  // this is not correct 
			S[o][t]=5;
	}
}}


In the first loop, I save the the odds when they are equal to 1 in period 3. In the second loop, I want to assign the value 5 the remaining odds, I mean I try to assign values 5 by excluding save vector

How can I do that ? Thank you so much
i don't understand, but let me ask a dumb question..

is this what you want?

1
2
3
4
5
6
7
8
for (int o = 0; o < nbOdds; ++o) {
		for (int t = 0; t < nbWays; ++t) {
			if (S[o][3] == 1) {
				save.push_back(o);
			}	
                   else S[o][3] = 5; //??	
		}
	}
Hello Jonnin,

Thank you so much .Not exactly ,actually it is y mistake , I edited my code. The t indexes vary according to the o. So, I should exclude the o which are equal to 1 in period 3, what I did in save. I need to find remaining o, I should assign value 5 in their time windows , which is starting[o] and nbWays[o]
Topic archived. No new replies allowed.