mercredi 24 février 2016

I need help compressing this IF statment down as much as possible in C++

I have several IF statements that I would like to compress as much as possible so that each time in the array that the number 1 appears it will add 1 to the Ones INT.

if (Dice[1] == 1)
{
    Ones ++;
}

if (Dice[2] == 1)
{
    Ones ++;
}

if (Dice[3] == 1)
{
    Ones ++;
}

if (Dice[4] == 1)
{
    Ones ++;
}

if (Dice[5] == 1)
{
    Ones ++;
}

Aucun commentaire:

Enregistrer un commentaire