Currently I have multiple if-else loops in my code, such as:
if (a > 2 && a < 4)
{
// do something
}
else if (a > 4 && a < 6)
{
// do something
}
else if (a > 6 && a < 8)
{
// do something
}
... and so on.
is there a way to re-arrange this into a simpler FOR loop? or any other loop which can make the code more optimized?
Aucun commentaire:
Enregistrer un commentaire