samedi 25 novembre 2017

Compare entire array lines for a set of variables

What i am trying to do is simple: i want to compare an entire line of an array in search of a set of variables in order like this:

var[2][]=={1,2,3,4,5} //all at the same time

instead of

var[2][0]==1 && var[2][1]==2 && var[2][2]==3 && var[2][3]==4 && var[2][4]==5 //one by one

or maybe

vartwo[4][3...7]==var[2][] ou vartwo[4][]==var[2][]

void main() {
    int i,var[5];
    puts("enter values:");

    for(;i<5;i++) {
        scanf("%d",&var[i]);
    };

    if(var[]=={1,1,1,0,0,0}) {
        //do stuff
    } else if (var[]=={1,2,3,5,2}) {
        //do something else
    }
    .
    .
    .
    } else {
        //not found
    }
}

Aucun commentaire:

Enregistrer un commentaire