lundi 20 septembre 2021

How can I replace this code with one if statement? [closed]

For the sake of challenge, how can I replace this code with only one if statement?

unsigned int x, y;
cin>>x;
if((x>=0)&&(x<=1)) y = 1;
else if (x<=3) y = 2;
    else if(x<=5) y = 3;
        else y = 6;

Aucun commentaire:

Enregistrer un commentaire