mardi 8 décembre 2015

multiple 'if...else...' statement in one line in c++

How to do if i want to get this code into one line?

if (count >= 0 && count <= 199) {
        return 1;
    } else if (count >= 200 && count <= 399) {
        return 2;
    } else if (count >= 400 && count <= 599) {
        return 3;
    } else if (count >= 600 && count <= 799) {
        return 4;
    } else {
        return 5;
    }

I'm just figuring is there any shortcut for this few line of codes.

Aucun commentaire:

Enregistrer un commentaire