At the moment, I am having to write out multiple for-loops which all do the same task, with the differences being in the initialization, condition, and the de/incrementation within the for-loops themselves.
Here is an example of something similar I have so far:
if(some_bool_condition)
{
for(int i = 0; i < 5; i++)
{
// do something
}
}
else
{
for(int i = 10; i >= 5; i--)
{
// do same thing
}
}
Is there a trick or technique I can use to merge these for-loops together?
Aucun commentaire:
Enregistrer un commentaire