how to change the following code from an if statement to a switch. is it possible to increment the speed[0] according to the sequence showing below(0,0,0,1,1,1,2,2,2,2) the variable node is of a type object.
if (node->speed[0] > system->velocity)
node->speed[0] = pSystem->velocity;
else if (node->speed[0] < pSystem->nVelocity)
node->speed[0] = pSystem->nVelocity;
if (node->speed[1] > pSystem->velocity)
node->speed[1] = pSystem->velocity;
else if (node->speed[1] < pSystem->nVelocity)
node->speed[1] = pSystem->nVelocity;
if (node->speed[2] > pSystem->velocity)
node->speed[2] = pSystem->velocity;
else if (node->speed[2] < pSystem->nVelocity)
node->speed[2] = pSystem->nVelocity;
Aucun commentaire:
Enregistrer un commentaire