Trying to check if a user input is equal to either 1, 5, 10, 25, or 100, but I'm not sure how else to do it besides having to type out if(user_input != 1 || user_input != 5 ...etc)
, especially since I'm going to be repeating this code many times. I've seen people using
switch(user_input){
case 1:
case 5:
...etc
case 100:
{do stuff}
break;
default:
{etc}
}
but that just seems messy to me. Is there no better way to go about it?
Aucun commentaire:
Enregistrer un commentaire