- We do a cycle over the whole range
[0, 25) ; - We get a function of the index and the zone, which returns
true if the element requires processing; - Combine it all.
bool use(int zone, int i) { switch(zone) { case 0: return i < 6 || i > 19; case 1: return i > 6 && i < 19; default: return true; } } for(int i = 0; i < 25; ++i) { if(use(zone, i)) { // обрабатываем элемент } }
To reduce the number of iterations, you can use a different approach: return the next index for each pair {index, zone}.
int inc(int zone, int i) { ++i; switch(zone) { case 0: { if(i >= 6 && i <= 19) { i = 20; // следующий после разрыва } break; } case 1: { if(i < 6) { i = 6; } else if(i > 19) { i = 25; // последний в диапазоне } } } return i; }
In essence, this will be a preliminary implementation of the idea of iterators, which was suggested by @ igor-karpenko in its response.
for(int i = 0; i < 25; i = inc(zone,i) { // обрабатываем элемент }
PS All "magic" constants should, of course, be replaced by the named. In general, you should not take the proposed code as ready for implementation. This is just a sketch to demonstrate the idea.
i<6 && i>19are not clear. And the 4-dimensional arrayGr[i][side][run][ell]is too much. - αλεχολυτ