mercredi 24 mai 2017

Satisfy two conditions with a single if in C++

Is there any way to simultaneously satisfy two conditions in C++?

I have a list of

 x and y
-1    -1
-1     0
-1     1
 0    -1
 0     0
 0     1
 1    -1
 1     0
 1     1

So I want to use all of them combination in a equation such as:

a = x+y (example)

however I want to exclude the situation in which x and y are = 0 simultaneously.

so I tried:

if(x!=0 && y!=0){
a = x+y;
}

But that excludes every case when x or y are equal to 0 and not just the point x,y = (0,0) as I want.

How can I solve that?

Aucun commentaire:

Enregistrer un commentaire